欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

關(guān)于bootstrap日期轉(zhuǎn)化,bootstrap-editable的簡(jiǎn)單使用,bootstrap-fileinput的使用詳解

 更新時(shí)間:2017年05月12日 15:13:46   作者:勤奮的小鑫0  
這篇文章主要介紹了關(guān)于bootstrap日期轉(zhuǎn)化,bootstrap-editable的簡(jiǎn)單使用,bootstrap-fileinput的使用,需要的朋友可以參考下

數(shù)據(jù)庫(kù)中為datetime類型,.net讀取數(shù)據(jù)已Json格式發(fā)回給前臺(tái)頁(yè)面:例如:使用bootstrap表格插件Ⅹ

 formatter: function (value, row, index) {
            var date = new Date(parseInt(value.slice(6)));
            return date.getFullYear() + '-' + parseInt(date.getMonth() + 1) + '-' + date.getDate() + " " + date.getHours() + ":" + date.getMinutes()+":"+date.getSeconds();
          }

使用bootstrap-editable時(shí)需要引用

<script src="~/Scripts/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script src="~/Scripts/bootstraptable/dist/extensions/editable/bootstrap-table-editable.min.js"></script>

初始化時(shí):

{
          field: 'SkuPurchasePrice',
          title: '采購(gòu)價(jià)',
          align: 'center',
          editable: {
            type: 'text',
            title: '采購(gòu)價(jià)',
            validate: function (v) {
              if (v < 0) return '采購(gòu)價(jià)不能小于0';
            }
          }
        }, {
          field: 'QtyAvailable',
          title: '庫(kù)存可用量',
          align: 'center',
          editable: {
            type: 'text',
            title: '庫(kù)存可用量',
            validate: function (v) {
              if (v < 0) return '庫(kù)存可用量不能小于0';
            },           
          },          
        }

事件:

onEditableSave: function (field, row, oldValue, $el) {
          $.ajax({
            type: 'post',
            url: "@Url.Action("EditNumber")",
            dataType: 'JSON',
            data: { "row": JSON.stringify(row) },
            success: function (data) {
              if (data.ResultType == 0) {
                toastr.success(data.Message);
              }
              else {
                toastr.warning(data.Message);
              }
            },
            error: function () {
              toastr.error("出錯(cuò)了,請(qǐng)聯(lián)系管理員");
            }
          });
        }

bootstrap-fileinput使用:

引用

<script src="~/Scripts/AdminLTE2.3.0/bootstrap/js/fileinput.min.js"></script>

初始化:

 <label class="control-label col-sm-1">商品上傳</label>
              <div class="col-sm-2"><input type="file" id="ProductsUpload" name="ProductsUpload" /></div>
              <div class="col-sm-1"><a href="~/ProductsExcel/DownloadTemplate?type=5" rel="external nofollow" target="_blank">下載模板</a></div>
function initFileInput(ctrlName) {
      var control = $('#' + ctrlName);
      control.fileinput({
        language: 'zh', //語(yǔ)言
        uploadUrl: "@Url.Action("ExcelLeadingIn")", //action
        autoReplace: true,
        maxFileCount: 1, //最大上傳數(shù)量
        allowedFileExtensions: ["xlsx", "xls"],
        browseClass: "btn btn-primary", //按鈕樣式
        dropZoneEnabled: false,
        enctype: 'multipart/form-data',
        showRemove: true, //是否顯示刪除按鈕
        showBrowse: true, //顯示瀏覽圖片按鈕
        msgFilesTooMany: "選擇上傳的文件數(shù)量({n}) 超過允許的最大數(shù)值{m}!",
        msgInvalidFileExtension:"只支持.xlsx和.xls文件的格式上傳",
        fileActionSettings: {
          showUpload: false, //預(yù)覽圖片上傳按鈕
          showRemove: false, //預(yù)覽圖片remove按鈕
          showZoom: false //關(guān)閉預(yù)覽圖片按鈕
        }
      }).on('fileuploaded', function (event, data, previewId, index) {//上傳圖觸發(fā)事件
        if (data.response.state == 1) {
          $('#excelLendingDiv h5').html($('#excelLendingDiv h5').html() + data.response.result+"<br/>");
        }
        else {
          toastr.error(data.response.result);
        }
      }).on('filecleared', function (event) {//remove觸發(fā)事件
        control.show();
      });
    }

 后臺(tái)上傳:

 [HttpPost]
    public ActionResult ExcelLeadingIn()
    {     
      var files = Request.Files;
      string name=files.Keys[0].ToString();
      if (files != null && files.Count > 0)
      {       
        var file = files[0];        
        string path = Server.MapPath("~/Content/excel/") + file.FileName;//文件保存在當(dāng)前域名下的Content/excel/中
        file.SaveAs(path);       
        string mess = OfferServer.ProductsDetail.InsertExcel(path,file.InputStream,name);
        return Json(new { state = 1, result = mess });
      }
      return Json(new { state = 0, result = "上傳發(fā)生錯(cuò)誤,請(qǐng)檢查后重試" });
    }

以上所述是小編給大家介紹的關(guān)于bootstrap日期轉(zhuǎn)化,bootstrap-editable的簡(jiǎn)單使用,bootstrap-fileinput的使用詳解,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

最新評(píng)論