on demand parameter in kendo grid load

On demand event

  // Bouquet combo change event  
   $('#BooketID').live('change', function () {  
     FillChannelGridByBouquetID();  
   });  

set parameter for grid load

 /* Load kendo grid by bouquetID*/  
   function FillChannelGridByBouquetID() {  
     var a = {};  
     a.BooketID = $("#BooketID option:selected").val();  
     var mAGrid = $('#CustomerPackageChannelKendoGrid').data('kendoGrid');  
     mAGrid.dataSource.read(a);  
     }  

Grid

 $("#CustomerPackageChannelKendoGrid").kendoGrid({  
     dataSource:  
     {  
       transport:  
       {  
         read: "ChannelReadByBooketID",  
       },  
       schema:  
       {  
         model:  
         {  
           fields:  
           {  
             SelectColumn: {type: "boolean"},  
             ChannelID: { type: "string" },  
             BooketName: { type: "string" },  
             ChannelName: { type: "string" },  
           }  
         }  
       },  
       pageSize: 20,  
       serverPaging: false,  
       serverFiltering: false,  
       serverSorting: false  
     },  
     height: 200,  
     filterable: true,  
     groupable: true,  
     sortable: true,  
     resizable: true,                                  
     pageable:  
     {  
       refresh: false,  
       pageSizes: [20, 40, 60, 80, 100]  
     },  
     columns:  
     [  
       {  
         field: "SelectColumn", title: " ", width: "5%",  
         template: "<input type='checkbox' #= SelectColumn ? checked='checked':'' # class='chkbx' />"  
       },  
       { field: "ChannelID", title: "ChannelID", hidden: true, filterable: false, sortable: false },  
       { field: "BooketName", title: "Bouquet Name", width: "30%" },  
       { field: "ChannelName", title: "Channel Name", width: "30%" },  
     ]  
   });  

Controller:

 public JsonResult ChannelReadByBooketID(CustomerPackageViewModel booketModel)  
     {  
       var models = GetAllChannelByBooketID(booketModel.BooketID.ToString());  
       return Json(models, JsonRequestBehavior.AllowGet);  
     }     
  private List<ChannelViewModel> GetAllChannelByBooketID(string pBooketID)  
     {  
       Guid gBooketID;  
       if (!Guid.TryParse(pBooketID, out gBooketID))  
       {  
         return null;  
       }  
       var ViewModels = _bCService.BillingUnit.ChannelRepository.Get(t => t.BooketID == gBooketID).ToList().Select(  
          md => new ChannelViewModel  
          {  
            ChannelID = md.ChannelID,  
            ChannelName = md.ChannelName,  
            BooketID = md.BooketID,  
            BooketName = md.DJBL_tblBooket.BooketName  
          }).OrderBy(o => o.BooketName);  
       return ViewModels.ToList();  
     }  


Popular posts from this blog

WPF Crystal Report Viewer Using SAP

mvc razor textboxfor change event change another textboxfor value

ASP.NET MVC razor SAP Crystal report