model view controller - Bind results to kendoGrid -
in following code i'm binding grid results controller action. works perfect method not stopping loading. time methid executing. here code:
<script> $(function() { $("#invoices-grid").kendogrid({ datasource: { type: "json", transport: { read: { url: "@html.raw(url.action("list", "finances"))", type: "post", datatype: "json", data: additionaldata }, }, schema: { data: "data", total: "total", errors: "errors" }, error: function(e) { display_kendoui_grid_error(e); // cancel changes this.cancelchanges(); }, pagesize: 20, serverpaging: true, serverfiltering: true, serversorting: true }, databound: function () { var row = this.element.find('tbody tr:first'); this.select(row); }, columns: [ { field: "jobnumber", title: "@t("gp.invoice.fields.jobnumber")", template: '#= jobnumber #' }, { field: "customername", title: "@t("gp.invoice.fields.customername")", template: '#= customername #' }, { field: "departmentname", title: "@t("gp.invoice.fields.departmentname")", template: '#= departmentname #' }, { field: "dateinvoice", title: "@t("gp.invoice.fields.dateinvoice")", template: '#= dateinvoice #' }, { field: "validdays", title: "@t("gp.invoice.fields.validdays")", template: '#= validdays #' }, { field: "delivery", title: "@t("gp.invoice.fields.delivery")", template: '#= delivery #' }, { field: "payed", title: "@t("gp.invoice.fields.ispayed")", template: '#= (payed == 2) ? "Комп." : ((payed == 1) ? "ДЕ" : "НЕ") #' }, { field: "id", title: "@t("common.edit")", width: 100, template: '<a href="edit/#=id#">@t("common.edit")</a>' } ], pageable: { refresh: true, pagesizes: [5, 10, 20, 50] }, editable: { confirmation: false, mode: "inline" }, scrollable: false, selectable: true, change: function(e) { var selectedrows = this.select(); var jobid = parseint($(selectedrows).data('job-id')); var jobitemid = parseint($(selectedrows).data('job-item-id')); var result = $.get("@url.action("sidedetails", "production")/" + jobitemid); result.done(function(data) { if (data) { $(".job-edit .jobitemdetails").html(data); } }); var grid = $('#invoices-grid').data('kendogrid'); grid.datasource.page(1); }, rowtemplate: kendo.template($("#invoicerowtemplate").html()), }); }); </script>
controller code:
[httppost] public actionresult list(datasourcerequest command, financelistmodel model) { var searchstring = model.searchjobitemnumber; var ischecked = model.ischecked; var invoices = _invoiceservice.getallinvoices(searchstring, ischecked); var gridmodel = new datasourceresult { data = invoices.select(x => { var jobmodel = x.tomodel(); return jobmodel; }), total = invoices.totalcount }; return json(gridmodel, "application/json", jsonrequestbehavior.allowget); }
in databound
event handler, select
method called, triggers change
event, , there, page
method called, triggers new request , new databound
. in way have created endless loop.
i not sure purpose of paging in change handler, whole setup cannot work way - consider reworking it.
Comments
Post a Comment