asp.net mvc - kendo grid with more than one datasource -
i'm having 3 radio buttons.i have 3 different stored procedures called 3 different radio buttons. example: have kendo grid. want results displayed in same grid 3 radiobutton selection. findcustomer_result stored procedure call customers details. if select second radiobutton want resources stored procedure details display. please help.
@(html.kendo().grid<proj.data.findcustomer_result>() .name("customersearch") .columns(columns => { columns.bound(p => p.id).visible(false); columns.bound(p => p.firstname).width(130); columns.bound(p => p.lastname).width(100); columns.bound(p => p.address1).width(150); }) .datasource(datasource => datasource .ajax() //call getcustomer fetch details of customer .read(read => read.action("getcustomer", "customer") .data("functiontobind")) .serveroperation(false) ) .sortable() .scrollable() .filterable() .rowaction(row => row.htmlattributes.add("data-id", row.dataitem.id)) )
create viewmodel wich contains 3 radiobuttons:
public class myviewmodel { public int id {get;set;} public bool radio1 {get;set;} public bool radio2 {get;set;} public bool radio3 {get;set;} }
then fill viewmodel in controller (customer) , specified action (getcustomer)
public class customercontroller : controller { ....... public actionresult getcustomer([datasourcerequest] datasourcerequest gridrequest) { ilist<myviewmodel> myviewmodels = new list<myviewmodel>(); //fill viewmodels here stored procedures return json(myviewmodels.todatasourceresult(gridrequest)); } ........ }
then change view code follows:
@(html.kendo().grid<myviewmodel>() .name("customersearch") .columns(columns => { columns.bound(p => p.id).visible(false); columns.bound(p => p.radio1).width(130); columns.bound(p => p.radio2).width(100); columns.bound(p => p.radio3).width(150); }) .datasource(datasource => datasource .ajax() //call getcustomer fetch details of customer .read(read => read.action("getcustomer", "customer") .data("functiontobind")) .serveroperation(false) ) .sortable() .scrollable() .filterable() .rowaction(row => row.htmlattributes.add("data-id", row.dataitem.id)) )
Comments
Post a Comment