This is a migrated thread and some comments may be shown as answers.

dataSource.read() issue for IE 8 and Firefox 12

0 Answers 110 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 08 May 2012, 09:10 PM
1. Chrome and IE 9 seem to be fine.
2. Here is the scenario:
   I have a DataSource and a kendoGrid widget setup. Here is part of the code:

   $(document).ready(function () {
        // Monthly Detail data source         var monthlyDetailDataSource = new kendo.data.DataSource({             transport: {                 read: {                     url: '@HttpUtility.JavaScriptStringEncode(Url.Content("~/Home/GetMonthlyDetailData/"))',                     data: {                         asOf: function () {                             return $("#datePicker").val();                         },                         fund: function () {                             try {                                 var dataItem = getSelectedDataItem();                                 var fundCode = dataItem.Fund.split(" ")[0];                                 return fundCode;                             }                             catch (err) {                                 return "";                             }                         }                     }                 }             },             batch: true,             schema: {                 model: {                     fields: {                         MonthStarting: { type: "date" },                         Nav: { type: "number" },                         MonthReturn: { type: "number" },                         Ytd: { type: "number" },                         Ltd: { type: "number" }                     }                 }             },             sort: { field: "MonthStarting", dir: "desc" }         });         // Monthly Detail grid         $("#monthlyDetailGrid").kendoGrid({             height: 300,             scrollable: true,             selectable: true,             sortable: true,             columns: [                 { title: "Month", field: "MonthStarting", template: '#= kendo.toString(MonthStarting, "yyyy-MM (MMM)") #' },                 { title: "NAV", field: "Nav", width: "100px", template: '<span style="float:right">#= kendo.toString(Nav, "n4") #</span>' },                 { title: "Monthly", field: "MonthReturn", width: "100px", template: '<span style="float:right">#= kendo.toString(MonthReturn, "p2") #</span>' },                 { title: "YTD", field: "Ytd", width: "100px", template: '<span style="float:right">#= kendo.toString(Ytd, "p2") #</span>' },                 { title: "LTD", field: "Ltd", width: "100px", template: '<span style="float:right">#= kendo.toString(Ltd, "p2") #</span>' }             ],             dataSource: monthlyDetailDataSource         }).data("kendoGrid"); // more code goes here ...
    });
On document ready I'm hitting my MVC 3 action on the server and returning null instead of "real"
JsonResult. The code of the method:
        public JsonResult GetMonthlyDetailData(string asOf, string fund)         {             if (String.IsNullOrEmpty(fund))             {                 return null;                                                                    // This is an issue                 // return Json(new List<FundReturnHistory>(), JsonRequestBehavior.AllowGet);    // This fixes it             }                              var asOfDate = GetDateOrDefault(asOf);             var data = historyProvider.GetFundReturnHistory(asOfDate, fund).First();             return Json(data, JsonRequestBehavior.AllowGet);         }

 
After that the workflow usually is: the user makes a dropdown selection on the UI, 
and subsequently triggers dataSource.read(), in this case:
 $("#monthlyDetailGrid").data("kendoGrid").dataSource.read();
which will not work if I have returned null in the GetMonthlyDetailData() method. Returning empty Json there fixes the problem. Different browsers have different native support for Json, so returning null would be handled differently... But on top of all that I think the DataSource is being put into an error state which could be a bug, and it might be worth fixing it... ~ Boris

No answers yet. Maybe you can help?

Tags
Data Source
Asked by
Boris
Top achievements
Rank 1
Share this question
or