Hi,
Is is possible to change grid model at run time?
For example if I want add column layout when user click on expand button.
I am using infragistic grid using MVC project.
Thank you,
Dharmendra
Hello Dharmendra ,
I’m just following up to see if you’ve been able to resolve your issue. If you have any questions or concerns or if you need further assistance please let me know.
Best Regards,
Maya Kirova
Developer Support Engineer
Infragistics, Inc.
http://ko.infragistics.com/support
Hello Dharmendra,
Thank you for posting in our forum.
Generally when using LoadOnDemand that would make an ajax call to the server however it would trigger only the action defined on DataSourceUrl for the specific layout.
During that call you can specify the data that is to be send back to the client but you cannot change the initial grid model the grid has been loaded with on the server.
If in the data for the specific band you pass an additional field that you want to show you could add an additional column to the already existing layout on the client side by getting the child grid and adding the additional column specification to the columns collection. After that you’ll need to call databind. If you want to add the column when you expand a parent row you can handle the RowExapanding event and add the column then. For example:
$(document).ready(function () {
$("#grid1").live("ighierarchicalgridrowexpanding", function (evt, ui) {
var parentRow = ui.parentrow;
var child = $(parentRow).next().find("table[id*=grid1")[0];
var cols = $(child).igGrid("option", "columns");
cols.push({ headerText: "Data", key: "Data", dataType: "string" });
$(child).igGrid("dataBind");
});
Please refer to the attached sample. The grid model is define in the Index action . note that for the child layout there’s no “Data” column defined.
Expand the parent row and note that on rowexpanding we add that column and its displayed as expected in the child grid.
Let me know if you have any questions or concerns.
Developer Support Engineer II