Kendo UI: Runtime datasource updates

Q1. How to update the data parameter  inside the data source when calling read method at run time?
Ans:  This example is with grid control and dropdownlist. First is parameter name and the second will be actual value. The code marked in Red should be inside document.ready();

 
Mgrid.data("kendoGrid").dataSource.read({ Id: Id });  
 mmdd.data("kendoDropDownList").dataSource.read({ type: type });  

 Example:  
 gridDataSource = new kendo.data.DataSource({  
     type: "json",  
     transport: {  
       read: {  
         url: crudServiceBaseUrl + "/GetCurrentUserGMap/",  
         contentType: "application/json; charset=utf-8",  
         dataType: "json",  
         type: "post",  
         data: { Id: Id }  
       },  
       parameterMap: function (options) {  
         return JSON.stringify(options);  
       }  
     },  
     batch: true,  
     pageSize: 30,  
     schema: {  
       model: {  
         id: "Id",  
         fields: {  
           UserName: { editable: false, nullable: false },  
           GroupName: { editable: false, nullable: false }  
         }  
       }  
     }  
   });   
 Mgrid= $("#grid").kendoGrid({  
     dataSource: gridDataSource,  
     height: 350,  
     pageable: true,  
     editable: false,  
     rowTemplate: kendo.template($("#rowTemplate").html())  
   });  
 function UpdateData() {  
         Id = OUEventArgunments.OuId.split('_')[1];  
         type = OUEventArgunments.OuTypeId;  
         Mgrid.data("kendoGrid").dataSource.read({ Id: Id });  
 }  

Q2. How to set the default text to the dropdownlist  at run time?

Ans:

  mmdd.data("kendoDropDownList").refresh();  
 $("#dduser").val("").data("kendoDropDownList").text("--Choose User--");  

Published by Nirbhay

Technology Geek,Blogger,Reviewer

One thought on “Kendo UI: Runtime datasource updates

Leave a reply to Anoop C M Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.