Savan Parmar

Savan Parmar

  • NA
  • 11
  • 8.3k

Create and Bind datasource to Kendo Grid from Jquery

Jul 10 2017 5:46 AM
Hello guys,
 
i am working on Asp.Net MVC Project. i have to creted and initialize kendo grid from jquery file. the function that create kendo grid in jquery is as below
  1. function initializeGrid(gridName, url, onSelectFunction) {  
  2.     onSelectFunction = onSelectFunction || null;  
  3.     var transport = {  
  4.         read: {  
  5.             //type: "POST",  
  6.             url: url,  
  7.             dataType: "json"  
  8.         }  
  9.     };  
  10.     var dataSource = new kendo.data.DataSource({  
  11.         transport: transport,  
  12.         pageSize: 30,  
  13.         schema: {  
  14.             model: {  
  15.                 id: "ClientID",  
  16.                 fields: {  
  17.                     ClientID: { type: "number", editable: false },  
  18.                     ClientName: { type: "string", validation: { required: true } }  
  19.                 }  
  20.             }  
  21.         }  
  22.     });  
  23.   
  24.     $("#" + gridName).kendoGrid({  
  25.         dataSource: dataSource,  
  26.         scrollable: true,  
  27.         height: 550,  
  28.         selectable: "multiple cell",  
  29.         filterable: true,  
  30.         columns: [  
  31.         {  
  32.             field: "ClientID",filterable: false,width:100  
  33.         },  
  34.         { Template: ("") },  
  35.         {  
  36.             field: "ClientName",title: "Client Name",width: 200  
  37.         }  
  38.     ]  
  39.     });  
  40.     $("#" + gridName).data("kendoGrid").bind();  
  41.     //$("#" + gridName).attr("data-val-number", "Invalid input.");  
  42. }  
using this code i am trying to create a grid that will have two columns,   1 is client id which will be of check box type and second will be client name. i am passing the URL of controller in the function syntax as parameter from where the data should be loaded. in another jquery file i am calling this function like this 
  1. initializeGrid("client""/Clients/GetDataForCombo"null);  
the end result is not what i wanted. it is not showing grid with the datasource instead it is showing grid area with white background.
 
 
Regards,
 
Savan Parmar

Answers (1)