Hi,
I am new to MVC5. Currently i am working on the grid with drop downlist bind it from the Model. In the below code snippet, each row has a column "Action List" and ActionResult data type is List<SelectListItem>. Each item in the drop down should be a hyper link and when user selects an item from drop down then call the javascript, based on the selected value i will create a Tab using HTML5 tab control.
My View looks like
@(Html.Infragistics().Grid(Model.Students).ID("grdOrderSearch").Height("500px").AutoGenerateColumns(false).AutoGenerateLayouts(false).RenderCheckboxes(true).PrimaryKey("ID").FixedHeaders(false).Columns(column =>{ column.For(x => x.Name).HeaderText("Column1"); column.For(x => x.Address2).HeaderText("Column2"); column.For(x => x.Address1).HeaderText("Column3"); //column.For(x => x.ActionsResult).HeaderText("Action List").Template(Html.DropDownListFor(x => x.selectedAction, x.ActionsResult, new { @class = "select_box" }));}).AlternateRowStyles(true).DataBind().Render())
How to achieve this? Please help me
I have the script ready for how to generate the tab, so i need help to populate the drop downlist with links as items and click on them pass the dropdown selected value.
Hi Venkat,
Thank you for posting in our forums!
I recommend using the ComboEditor to achieve this. You can set the column to use an igCombo for editing and handle the selectionChanged event.
I have attached a sample that demonstrates how you could achieve this. If you have any further questions or concerns with this, please let me know.
Thank you for the response Michael.
In your example, you are reading the Categories from the ViewBag, which is static list same across all the rows in the Grid. But i have it as property in the Grid datasource. Categories are different for each row. I can not use the static list from ViewBag, it is different list for each product.
My modal looks like
class Product { public int ProductID; public string ProductName; public List<SelectListItem> Categories; }
Source of the grid is: List<Product> ProductList
How can we read the Categories from each Product in the ProductList and bind it to the combo in the Categories column?
Thank you in advance.
Thank you for the clarification.
In this scenario, I will need some more time to investigate how to best achieve this.
I will have more information on my findings for you by next Monday.
In order to render a different dropdown list for each item, you should handle the template for the column a little differently.
Each option will need to be rendered manually, so using a DropDownListFor will not work. Instead, if you use our rendering engine you can render each option individually.
I have modified and re-attached my sample to demonstrate how this can be accomplished. If you have any further questions or concerns with this, please let me know.