or

$(document).ready(function () { $("#ordersGrid").kendoGrid({ pageable: true, sortable: true, detailTemplate: kendo.template($("#template").html()), detailInit: detailInit, dataBound: function () { this.expandRow(this.tbody.find("tr.k-master-row").first()); }, columns: [ { field: "shopOrderHexID", title: "ID", }, { field: "characterName", title: "Pilot" }, { field: "CreatedDate", title: "Created", format: "{0:yyyy.MM.dd}" }, { field: "LastModifiedDate", title: "Last Modified", format: "{0:yyyy.MM.dd}" }], dataSource: { transport: { read: "/ShopOrders/OrderList", dataType: "json", type: "POST", contentType: "application/json; charset=utf-8", data: {} }, parameterMap: function (options) { return JSON.stringify(options); }, schema: { model: { fields: { shopOrderHexID: { type: "string" }, characterName: { type: "string" }, characterID: { type: "number" }, CreatedDate: { type: "date" }, LastModifiedDate: { type: "date" } } }, data: "Data", total: "Total" }, pageSize: 5, serverPaging: true, serverSorting: true, serverFiltering: true } });});// returns a list of products in a specific category for the active userpublic JsonResult OrderList([Kendo.Mvc.UI.DataSourceRequest]Kendo.Mvc.UI.DataSourceRequest request){ var userID = User.Identity.GetUserId(); // build results, make sure to return only orders from current user var orders = repository.shopOrders .Where(order => order.userID == userID) // avoid circular reference by converting to view model, and flatten the model .Select(e => new ShopOrderViewModel { shopOrderID = e.shopOrderID, characterName = e.characterName, characterID = e.characterID, CreatedDate = e.CreatedDate, LastModifiedDate = e.LastModifiedDate, totalCost = e.orderItems .Sum( o => o.quantity * o.price ), paymentAmount = ( e.shopOrderPaymentRecords.Count() > 0 )? e.shopOrderPaymentRecords.Sum(p => p.payment):0, //paid = (paymentAmount >= totalCost) }) // convert to list so I can manipulate the data a little easily .ToList(); // populate the hex value of the shopOrderID (linq to objects/sql doesn't like doing this directly) for (int i = 0; i < orders.Count(); i++) { orders.ElementAt(i).shopOrderHexID = orders.ElementAt(i).shopOrderID.ToString("X8"); } // apply filter to the results... that's what this does right? Kendo.Mvc.UI.DataSourceResult result = orders.ToDataSourceResult(request); // return data as json return Json(result, JsonRequestBehavior.AllowGet);}<div id="grid" style="margin-bottom: 20px"></div><!-- Data sources for supporter and supportee AutoComplete. --><script type="text/javascript"> var supporterDataSource = new kendo.data.DataSource({ transport: { read: { url: "<%= supporters_admin_customer_support_clients_url + '.json' %>", dataType: "json" }, schema: { user_id: { type: 'number' }, full_name: { type: 'string' } } } }); var supporteeDataSource = new kendo.data.DataSource({ transport: { read: { url: "<%= supportees_admin_customer_support_clients_url + '.json' %>", dataType: "json" }, schema: { user_id: { type: 'number' }, full_name: { type: 'string' } } } });</script><!-- Popup editor template for customer support client grid --><script id="popup_editor" type="text/x-kendo-template"> <div class="k-edit-label" style="padding-right: 10px"> <label for="SupporterName">Customer Support Rep</label> </div> <input name="SupporterName" data-bind="value:supporter_name" data-value-field="user_id" data-text-field="full_name" data-source="supporterDataSource" data-role="autocomplete" /> <div class="clear"></div> <div class="k-edit-label" style="padding-right: 10px"> <label for="SupporteeName">Researcher</label> </div> <input name="SupporteeName" data-bind="value:supportee_name" data-value-field="user_id" data-text-field="full_name" data-source="supporteeDataSource" data-role="autocomplete" /></script><!-- Customer support client grid --><% content_for :javascript do %> var crudServiceBaseUrl = "<%= admin_customer_support_clients_url %>", dataSource = new kendo.data.DataSource({ transport: { read: { url: crudServiceBaseUrl + '.json', dataType: "json" }, create: { url: crudServiceBaseUrl + '.json', type: "POST", dataType: "json" }, update: { url: function (data) { return crudServiceBaseUrl + '/' + data.id + '.json'; }, type: "PUT", dataType: "json" }, destroy: { url: function (data) { return crudServiceBaseUrl + '/' + data.id + '.json'; }, type: "DELETE", dataType: "json" }, parameterMap: function(options, operation) { if (operation !== "read" && options.models) { return {models: kendo.stringify(options.models)}; } } }, pageSize: 20, serverPaging: false, serverFiltering: false, serverSorting: false, schema: { model: { id: "id", fields: { id: { editable: false, type: 'number' }, supporter_id: { type: 'number' }, supporter_name: { type: 'string' }, supportee_id: { type: 'number' }, supportee_name: { type: 'string' }, created_at: { editable: false, type: 'date' }, updated_at: { editable: false, type: 'date' } } } } }); $("#grid").kendoGrid({ dataSource: dataSource, editable: { mode: "popup", template: kendo.template($("#popup_editor").html()) }, edit: function(e) { $(e.container) .find("input[name='SupporterName']") .data("kendoAutoComplete") .bind("change", function(e) {}); $(e.container) .find("input[name='SupporteeName']") .data("kendoAutoComplete") .bind("change", function(e) {}); }, toolbar: ["create"], height: 430, filterable: true, sortable: true, pageable: true, columns: [{ field: "supporter_name", title: "Customer Support Rep", type: "string" }, { field: "supportee_name", title: "Researcher", type: "string" }, { field: "created_at", title: "Created At", type: "date", format: "{0:dd-MMM-yyyy hh:mm tt}", parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"] }, { field: "updated_at", title: "Updated At", type: "date", format: "{0:dd-MMM-yyyy hh:mm tt}", parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"] }, { command: ["edit", "destroy"], title: " ", width: "175px" }] });<% end %><div id="mainContainer"> <ul id="list-container"> </ul></div>$.when( Event.getEventsNearby( position.coords.latitude, position.coords.longitude, radius, limit, offset, key ) ).done( function( response ) { var template = Handlebars.compile( $( '#eventListTemplate' ).html() ); $("#list-container").kendoMobileListView({ template : template, dataSource: kendo.data.DataSource.create(results) }); } );$.when( User.getUsersNearby( position.coords.latitude, position.coords.longitude, Usr_radius, Usr_limit, Usr_offset ) ).done( function( response ) { var template = Handlebars.compile( $( '#userListTemplate' ).html() ); $("#list-container").kendoMobileListView({ template : template, dataSource: kendo.data.DataSource.create( results ) });});