Hi,
I try to create a generic grid which will map severals tables and I'll be able to modify the content of those table by only one grid but I've some trubble.
Idea is having only one grid which will take an object like and load all the porperties automatically. We will be able to save data by save button. I took the example you have in your website which is Basic Edit of grid.
I prepared an example at I join it to you with this mail. You have only two pages
HomeController:
public ActionResult SaveGenericData()
This function save the data modified in grid, this I want to it in a generic way
public ActionResult GetGenericData()
This function send a Queryable object, this method I would send a generic data
Index.html:
You will find the grid:
@model IQueryable<TestCountry>
this I want it to take a generic object
@(Html.Infragistics()
.Grid(Model)
.ID("Grid")
.PrimaryKey("CountryId")
Here it takes a primary key, it should be a dynamic key calculated from generic class
Thank you for your help
Hello cem ozbas,
Thank you for posting in our forums!
I recommend using the MVC ViewBag to achieve this. You can assign the values you want to reference in the View from the Controller.
This lets you do something like:
HomeController.cs:
ViewBag.GridPK = "CountryId";
Index.cshtml:
@(Html.Infragistics() .Grid(Model) .ID("Grid") .PrimaryKey(ViewBag.GridPK)
If you have any further questions or concerns with this, please let me know.
Hi Michael,
Thank you for your answer. You have just answered only %1 of what I needed. If you read my question carefully you will see it's more complicate and it is not that easy (for me). I'll try to explain a little bit more,
I have many table in my database (I use only two entites for this example)
TestCountry
CountryCode
CountryName
TestProduct
ProductCode
ProductName
...
... many other table
I want to be able to load each table on the screen by using only one grid. This grid will read all the properties of the entity and show all in the screen. Then I will be able to modify them by using standard functions of grid.
We are also using your products for on of our projet with winform and there, you can just give an entity and modify it directly without any trubble. I wonder if you have any possibilities to pass an entity and the grid do the rest.
I prepared an mvc solution that you will find it in the page. Please try to produce an example on this solution than it will be easier to understand each other.
Thank you