关于bootstrap日期转化,bootstrap-editable的简单使用,bootstrap-fileinput的使用详解

这篇文章主要介绍了关于bootstrap日期转化,bootstrap-editable的简单使用,bootstrap-fileinput的使用,需要的朋友可以参考下

数据库中为datetime类型,.net读取数据已Json格式发回给前台页面:例如:使用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时需要引用

 

初始化时:

 { field: 'SkuPurchasePrice', title: '采购价', align: 'center', editable: { type: 'text', title: '采购价', validate: function (v) { if (v <0) return '采购价不能小于0'; } } }, { field: 'QtyAvailable', title: '库存可用量', align: 'center', editable: { type: 'text', title: '库存可用量', validate: function (v) { if (v <0) return '库存可用量不能小于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("出错了,请联系管理员"); } }); }

bootstrap-fileinput使用:

引用

 

初始化:

 
 function initFileInput(ctrlName) { var control = $('#' + ctrlName); control.fileinput({ language: 'zh', //语言 uploadUrl: "@Url.Action("ExcelLeadingIn")", //action autoReplace: true, maxFileCount: 1, //最大上传数量 allowedFileExtensions: ["xlsx", "xls"], browseClass: "btn btn-primary", //按钮样式 dropZoneEnabled: false, enctype: 'multipart/form-data', showRemove: true, //是否显示删除按钮 showBrowse: true, //显示浏览图片按钮 msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}!", msgInvalidFileExtension:"只支持.xlsx和.xls文件的格式上传", fileActionSettings: { showUpload: false, //预览图片上传按钮 showRemove: false, //预览图片remove按钮 showZoom: false //关闭预览图片按钮 } }).on('fileuploaded', function (event, data, previewId, index) {//上传图触发事件 if (data.response.state == 1) { $('#excelLendingDiv h5').html($('#excelLendingDiv h5').html() + data.response.result+"
"); } else { toastr.error(data.response.result); } }).on('filecleared', function (event) {//remove触发事件 control.show(); }); }

 后台上传:

 [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;//文件保存在当前域名下的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 = "上传发生错误,请检查后重试" }); }

以上所述是小编给大家介绍的关于bootstrap日期转化,bootstrap-editable的简单使用,bootstrap-fileinput的使用详解,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对html中文网网站的支持!

以上就是关于bootstrap日期转化,bootstrap-editable的简单使用,bootstrap-fileinput的使用详解的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » JavaScript 教程