With the Telerik KendoUI web Grid control, what are the requirements for us to get a value for filtering dates when using serverside filtering?
What we see when we filter on other columns - which is great, as we can easily parse this (strings for example) is:
|
filter[filters][0][field] |
|
filter[filters][0][operator] |
|
filter[filters][0][value] |
|
filter[logic] |
What we see when we filter on date columns is - there is no value to parse out here: (note: the value is missing for this date filter, but it was not missing in the string filter).
|
filter[filters][0][field] |
|
filter[filters][0][operator] |
|
filter[logic] |
Additional information about how we are using the date column in our grid:
Initialized with this column as a date:
field: "LastUpdated", title: "Updated", format: "{0:MM/dd/yyyy}"
Datasource for this grid has this column as a date:
LastUpdated: { type: "date", nullable: true }
Thank you,
Chris
<div id="example" class="k-content"> <div id="tweets-container" class="k-header k-menu-vertical"> <h3> Twitter feed</h3> <div id="search-box"> <label> Search for: <input type="text" value="html5" id="searchfor" class="k-textbox" /> </label> <button class="k-button" id="search"> search</button> </div> <div id="tweets"> <div> Loading ... </div> </div> </div> <script id="template" type="text/x-kendo-template"> <div class="tweet k-header"> <img width="48" height="48" src="#= profile_image_url #" alt="#= from_user #" /> #= FirstVal # </div> </script> <script> $(document).ready(function () { // create a template using the above definition var template = kendo.template($("#template").html()); var Product = kendo.data.Model.define({ id: "FirstID", fields: { "FirstVal": { type: "string" }, "SecondVal": { type: "string" } } }); var dataSource = new kendo.data.DataSource({ transport: { read: { url: "/ws/getservice.asmx/GetAllTestimonials", // the remove service url data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", // JSONP (JSON with padding) is required for cross-domain AJAX complete: function(data,xhr){ result = JSON.parse(data.d.resposeText); } } }, change: function () { // subscribe to the CHANGE event of the data source $("#tweets").html(kendo.render(template, dataSource.view())); } }); // read data from the remote service dataSource.read(); $("#search").click(function () { dataSource.read(); }); $("#searchfor").keydown(function (e) { if (e.keyCode === kendo.keys.ENTER) { dataSource.read(); } }); }); </script>[{"FirstID":1,"FirstVal":"Test","SecondVal":"TestOne"},{"FirstID":2,"FirstVal":"Test","SecondVal":"TestTwo"}]<input id="gradeCombo" data-role="combobox" data-bind="value: source.gradeValue"/><input id="gradeCombo" data-role="combobox" data-bind="value: source.gradeValue, text: source.gradeText"/>I have some working code which I am trying to convert to use the MVVM pattern. My code looks like the following:
To start with, I have a div tag like the following:
<div id="MyDiv" data-template="template" ></div>
My template looks like the following:
<script type="text/x-kendo-template" id="template">
<table>
<tr>
<td>My Numbers: </td>
#for (var i = 0; i < data.length; i++){#
<td><input type="text" value=#= data[i] # /></td>
#}#
</tr>
</table>
</script>
Finally the following script provides data to the template:
<script>
var rowTemplate = kendo.template($("#template").html());
function display() {
$("#MyDiv").html(rowTemplate({
data: ["1.2", "2.3", "3.4"]
}));
}
display();
</script>
When I run, the output shows the numbers 1.2, 2.3 and 3.4 in 3 inputboxes (each of which appears in 3 separate <td> tags) against a label, like the following:
My Numbers: 1.2 2.3 3.4
I have been trying to convert the above code to an MVVM pattern, but somewhy not getting it right. Could someone please guide me how to do this correctly?
@(Html.Kendo().Grid(Model.Companies) .Name("ClientBindGrid") .Columns(columns => { columns.Bound(c => c.CompanyName); columns.Bound(c => c.State); }) .Groupable() .Pageable() .Sortable() .Scrollable() .Filterable() .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false) // paging, sorting, filtering and grouping will be applied client-side .Read(read => read.Action("GetCompanies", "ManageCompanies", new { area = "api" })) ))<div class="k-widget k-grid" id="ClientBindGrid"><div class="k-grouping-header">Drag a column header and drop it here to group by that column</div><div class="k-grid-header"><div class="k-grid-header-wrap"><table cellspacing="0"><colgroup><col /><col /></colgroup><tr><th class="k-header k-filterable" data-field="CompanyName" data-title="Company Name" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="http://localhost:2337/CompanyMgmt/ManageCompanies">Company Name</a></th><th class="k-header k-filterable" data-field="State" data-title="State" scope="col"><a class="k-grid-filter"><span class="k-icon k-filter"></span></a><a class="k-link" href="http://localhost:2337/CompanyMgmt/ManageCompanies">State</a></th></tr></table></div></div><div class="k-grid-content" style="height:200px"><table cellspacing="0"><colgroup><col /><col /></colgroup><tbody><tr><td>H&H</td><td>CO</td></tr><tr class="k-alt"><td>H&H3333</td><td>CO</td></tr></tbody></table></div><div class="k-pager-wrap k-grid-pager"><a class="k-link k-state-disabled" data-page="1" href="#" title="Go to the first page"><span class="k-icon k-i-seek-w">seek-w</span></a><a class="k-link k-state-disabled" data-page="0" href="#" title="Go to the previous page"><span class="k-icon k-i-arrow-w">arrow-w</span></a><ul class="k-pager-numbers k-reset"><li><span class="k-state-selected" data-page="1">1</span></li></ul><a class="k-link k-state-disabled" data-page="2" href="#" title="Go to the next page"><span class="k-icon k-i-arrow-e">arrow-e</span></a><a class="k-link k-state-disabled" data-page="1" href="#" title="Go to the last page"><span class="k-icon k-i-seek-e">seek-e</span></a><span class="k-pager-info k-label">1 - 2 of 2 items</span></div></div><script> jQuery(function(){jQuery("#ClientBindGrid").kendoGrid({"columns":[{"title":"Company Name","field":"CompanyName","encoded":true},{"title":"State","field":"State","encoded":true}],"groupable":{},"pageable":{"buttonCount":10},"sortable":true,"filterable":true,"dataSource":{"transport":{"read":{"url":""}},"pageSize":10,"page":1,"total":2,"type":"aspnetmvc-ajax","schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"CompanyID":{"type":"number"},"CompanyName":{"type":"string"},"Address1":{"type":"string"},"Address2":{"type":"string"},"City":{"type":"string"},"State":{"type":"string"},"PostalCode":{"type":"string"},"ItemMargin":{"type":"number"},"ServicesMargin":{"type":"number"},"InvoiceTimeIncrement":{"type":"number"},"CashDiscountPct":{"type":"number"},"BaseServiceHourlyRate":{"type":"number"},"HourlyPremiumRush":{"type":"number"},"HourlyPremiumLate":{"type":"number"},"HourlyPremiumCustomerMaterial":{"type":"number"},"CreatedByID":{"type":"number"},"CreatedOn":{"type":"date"},"ModifiedBy":{"type":"number"},"ModifiedOn":{"type":"date"},"UserProfile":{"type":"object"},"UserProfile1":{"type":"object"},"FullAddress":{"editable":false,"type":"string"}}}},"data":{"Data":[{"CompanyID":2,"CompanyName":"H\u0026H","Address1":"123 Mockinbird Lane","Address2":null,"City":"Denver","State":"CO","PostalCode":"12345","ItemMargin":0,"ServicesMargin":0,"InvoiceTimeIncrement":0,"CashDiscountPct":0,"BaseServiceHourlyRate":0,"HourlyPremiumRush":0,"HourlyPremiumLate":0,"HourlyPremiumCustomerMaterial":0,"CreatedByID":0,"CreatedOn":"\/Date(-62135571600000)\/","ModifiedBy":0,"ModifiedOn":"\/Date(-62135571600000)\/","UserProfile":null,"UserProfile1":null,"FullAddress":"Denver, CO 12345"},{"CompanyID":3,"CompanyName":"H\u0026H3333","Address1":"123 Mockinbird Lane","Address2":null,"City":"Denver","State":"CO","PostalCode":"12345","ItemMargin":0,"ServicesMargin":0,"InvoiceTimeIncrement":0,"CashDiscountPct":0,"BaseServiceHourlyRate":0,"HourlyPremiumRush":0,"HourlyPremiumLate":0,"HourlyPremiumCustomerMaterial":0,"CreatedByID":0,"CreatedOn":"\/Date(-62135571600000)\/","ModifiedBy":0,"ModifiedOn":"\/Date(-62135571600000)\/","UserProfile":null,"UserProfile1":null,"FullAddress":"Denver, CO 12345"}],"Total":2}}});});</script><script type="text/javascript"> $(document).ready(function() { GetData(); }); function GetData() { var Num = parseInt(document.getElementById("txt_Rows").value); $.ajax({ type: "POST", url: "UserActions.aspx/Method", data: "{'Number' : " + Num + "}", contentType: "application/json; charset=utf-8", dataType: "json", error: function(xhr, status) { alert(status + " - " + xhr.responseText); }, success: function(msg) { $("#Grid").kendoGrid({ dataSource: { data: msg.d, pageSize: 10, schema: { model: { fields: { Column1: { type: "string" } } } } }, height: 400, scrollable: true, sortable: false, pageable: true, resizable: true, columns: [ { field: "Column1", title: "Column1"} ] }); } }); }</script><div id="Grid"></div><div align="right"> <asp:TextBox ID="txt_Rows" runat="server" Text="10" Width="40px" MaxLength="4"></asp:TextBox> <input id="btn_LoadData" type="button" value="Load" onclick="GetData();return false;" /></div>[System.Web.Services.WebMethod]public static List<Data> Method(int Number){ // Get data from database List<Data> DataList = new List<Data>(); // Load data into list - create new instance of class Data return DataList;}public class Data{ public string Column1 { get; set; }}<div class="k-content"> <div id="tabs"> <ul> <li class="k-state-active">AREA</li> </ul> <div> <div id="grid"> </div> </div> </div> </div><script type="text/javascript">$().ready(function() { $("#tabs").kendoTabStrip(); var baseUrl = "<?php echo $this->baseUrl();?>"; var dataSource = new kendo.data.DataSource({ transport: { read: { url: baseUrl + "/Maintenance/Area/json", dataType: "json" } }, batch: true, pageSize:20, schema: { model: { id: "area_id", fields: { area_id: {editable:false, nullable:true}, area_code: {type:"string"}, area_desc: {type:"string"} } } } }); $("#grid").kendoGrid({ dataSource: dataSource, navigatable: true, pageable:true, height:400, columns: [ {field:"area_code", title:"CODE"}, {field:"area_desc", title:"DESCRIPTION"} ], selectable: "row", change: onSelect }); function onSelect(e) { var id; var splitter = $("#splitter").data("kendoSplitter"); splitter.ajaxRequest("#detail", baseUrl + "/Maintenance/Area/detail", {id: 8}); var selected = $.map(this.select(), function(item) { id = $(item ).attr('data-id'); //return $(item).text(); }); alert(id); //loadPaneDetail(id); } });</script>