bootstrap-table接合knockout.js

时间:2022-12-12 18:56:31
1 function responseHandler(data) {
2         if (data.ErrorNo > 0) {
3             return;
4         }
5 
6         var count = data.Data.TotalRowCount;
7         var results = data.Data.Items;
8         return { total: count, rows: results };
9     }
 1 $.fn.tabletobootstrapTable = function (settings, bindingContext) {
 2         settings = settings || {};
 3         $(this).each(function () {
 4             if (this.grid) { return; }
 5             var element = $(this).width('99%'),
 6                 options = { datatype: 'local', colModel: [], colNames: [], height: 'auto', altRows: true },
 7                 pagerOptions = ko.utils.extend({ target: '#pager', rowNum: 10, rowList: [10, 20, 50] }, settings.pager),
 8                 idParamName = settings.rowid || 'id';
 9 
10             pagerOptions.pager = $(pagerOptions.target).length == 0 ? null : pagerOptions.target;
11             $.extend(options, pagerOptions, { width: element.width(), caption: $('caption', element).text(), localReader: { id: idParamName }, responseHandler: responseHandler });
12             
13             buildColModel(element, options, bindingContext);
14             element.empty().jqGrid(options);
15 
16 
17         });
18     };
以往用的不正确.特此记录.