關(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)文章
JavaScript代碼性能優(yōu)化總結(jié)(推薦)
下面小編就為大家?guī)硪黄狫avaScript代碼性能優(yōu)化總結(jié)(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考,一起跟隨小編過來看看吧,祝大家游戲愉快哦2016-05-05JavaScript之class繼承_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理
這篇文章主要介紹了JavaScript之class繼承,新的關(guān)鍵字class從ES6開始正式被引入到JavaScript中。class的目的就是讓定義類更簡(jiǎn)單,有興趣的可以了解一下2017-07-07JS實(shí)現(xiàn)切換標(biāo)簽頁(yè)效果實(shí)例代碼
這篇文章介紹了JS實(shí)現(xiàn)切換標(biāo)簽頁(yè)效果實(shí)例代碼,有需要的朋友可以參考一下2013-11-11微信小程序WebSocket實(shí)現(xiàn)聊天對(duì)話功能
這篇文章主要為大家詳細(xì)介紹了微信小程序WebSocket實(shí)現(xiàn)聊天對(duì)話功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-07-07使用JS實(shí)現(xiàn)圖片展示瀑布流效果的實(shí)例代碼
下面小編就為大家?guī)硪黄褂肑S實(shí)現(xiàn)圖片展示瀑布流效果的實(shí)例代碼。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-09-09微信小程序網(wǎng)絡(luò)層封裝的實(shí)現(xiàn)(promise, 登錄鎖)
這篇文章主要介紹了微信小程序網(wǎng)絡(luò)層封裝(promise, 登錄鎖),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-05-05JS中的Replace()傳入函數(shù)時(shí)的用法詳解
這篇文章主要介紹了JS中的Replace()傳入函數(shù)時(shí)的用法詳解,replace方法的語(yǔ)法是:stringObj.replace(rgExp, replaceText)關(guān)于js replace 傳入函數(shù)的用法,大家通過本文學(xué)習(xí)吧2017-09-09