I am trying to fetch and load data to a kendo grid using some parameters. But when I am using date parameter, format of date is changing hence showing me wrong dates in server side.
As an example as a parameter I am using: new Date("April 01, 2016"). But in server side it becomes 04/01/2016 which is wrong.
function passFilterCstDetails() {
var statemenetInquiryParameter = {};
statemenetInquiryParameter.isPrintZero = true;
statemenetInquiryParameter.isPrintPayments = true;
statemenetInquiryParameter.isPrintAdjust = true;
statemenetInquiryParameter.cst_stmt_from = new Date("April 01, 2016");
statemenetInquiryParameter.cst_stmt_to = new Date("April 12, 2016");
statemenetInquiryParameter.customerCode = 007;
return {
statemenetInquiryParameter: statemenetInquiryParameter
}
}
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
@(Html.Kendo().Grid<ServicePROWeb.ServiceProWCFService.CstTran>()
.Name("gridCustomerCstTranDetails")
.Columns(columns =>
{
columns.Bound(p => p.cst_inv_date).Title("Invoice Date").HtmlAttributes(new { @style = "text-align: right;" }).Format(Session["DisplayFormat_GridDate"].ToString()).Width(80);
columns.Bound(p => p.cst_type).Title("Type").Width(80);
columns.Bound(p => p.cst_ih_invno).Format("{0:n2}").HtmlAttributes(new { @style = "text-align: right;" }).Filterable(false).Title("Invoice Number").Width(80);
columns.Bound(p => p.cst_dr_amount).Format("{0:n2}").HtmlAttributes(new { @style = "text-align: right;" }).Filterable(false).Title("Debit").Width(80);
columns.Bound(p => p.cst_cr_amount).Format("{0:n2}").HtmlAttributes(new { @style = "text-align: right;" }).Filterable(false).Title("Credit").Width(80);
columns.Bound(p => p.cst_dr_balance).Format("{0:n2}").HtmlAttributes(new { @style = "text-align: right;" }).Filterable(false).Title("Balance").Width(80);
})
.Selectable()
.Sortable()
.Scrollable()
.Resizable(resize => resize.Columns(true))
.HtmlAttributes(new { style = "cursor:pointer;height:auto;width:auto;margin-top: 0px;" })
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("LoadCustomerStatementEnquiryDetails", "Stage").Data("passFilterCstDetails")))
)
</div>
</div>
public class StatemenetInquiryParameter
{
public decimal customerCode { get; set; }
public DateTime cst_stmt_from { get; set; }
public DateTime cst_stmt_to { get; set; }
public bool isPrintZero { get; set; }
public bool isPrintPayments { get; set; }
public bool isPrintAdjust { get; set; }
}
public ActionResult LoadCustomerStatementEnquiryDetails([DataSourceRequest]DataSourceRequest request, StatemenetInquiryParameter statemenetInquiryParameter)
{
List<CstTran> l = new List<CstTran>();
for (int i = 0; i < 12; i++)
{
CstTran c = new CstTran();
c.cst_inv_date = statemenetInquiryParameter.cst_stmt_from.AddDays(i);
c.cst_type = "I";
c.cst_ih_invno = i + 1;
c.cst_dr_amount = i;
c.cst_cr_amount = 0;
c.cst_dr_balance = c.cst_dr_balance + i;
l.Add(c);
}
return Json(l.ToDataSourceResult(request));
}
I too had this problem, i solved it by checking the data format at the time of saving.
1- find the data while saving
2- check the format and then save it, my data parameter is rsrc_dt
3- You may try this also, give format of data in field template like this one
4- Use DateEditor