Reputation: 659
I'm having 3 radio buttons.I have 3 different stored procedures that is called for 3 different radio buttons. Example: I have a kendo grid. I want the results to be displayed in the same grid for all 3 radiobutton selection. FindCustomer_Result is my stored procedure to call the customers details. Now if i select the second radiobutton i want resources Stored procedure details to 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 to 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))
)
Upvotes: 1
Views: 701
Reputation: 821
Create a ViewModel wich contains your three 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 the ViewModel in your Controller (Customer) and specified Action (GetCustomer)
public class CustomerController : Controller
{
.......
public ActionResult GetCustomer([DataSourceRequest] DataSourceRequest gridRequest)
{
IList<MyViewModel> myViewModels = new List<MyViewModel>();
//fill ViewModels here from stored Procedures
return Json(myViewModels.ToDataSourceResult(gridRequest));
}
........
}
Then change your view Code as 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 to 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))
)
Upvotes: 1