I'm trying to make a Hierarchical Grid using my iggrid. My Model is a bit complex, how can I configure my grid to display this model in an hierarchical fashion? Here is my model;
public class RoleRightsModel { public string Module { get; set; } public List<ScreenType> ScreenType { get; set; } }
public class ScreenType { public string ScreenTypeName { get; set; } public List<Screen> Screen{ get; set; } }
public class Screen { public string ScreenName { get; set; } public List<Permission> Permission { get; set; } }
public class Permission { public bool CanAdd { get; set; } public bool CanEdit { get; set; } public bool CanDelete { get; set; } public bool CanPrint { get; set; } }
Basically I want the name of the nodes to be listed once(distinct) in a tree view like structure
For example:
[Module Grid]
(1) -Security Manger [ScreenType Grid]
(1a)-Report [Screen Grid]
(1aa)-Dashboard [Permission Grid]
-CanAdd - CanEdit -CanDelete -CanPrint (checkbox columns)
(1ab)-Screen2 [Permission Grid]
(1b)-Data entry [Screen Grid]
(1ba)-Screen3 [Permission Grid]
(1bb)-Screen4 [Permission Grid]
2 -System Admin [ScreenType Grid]
...
....
Hello,
Thank you for contacting Infragistics!
I have done some looking into this matter and have the following information. This behavior can be achieved by using the igHierarchicalGrid. You will have an igHierarchicalGrid for each main grid you want. Then on the child level you will create a columnLayout for each child grid you want to display. For example the following code would create to child grids. One for each column layout:
.ColumnLayouts(layout => { layout.For(x => x.Products) .ForeignKey("CategoryID") .PrimaryKey("ProductID") .AutoGenerateColumns(false) .DataSourceUrl(Url.Action("BindProduct") .Columns(column => { column.For(x => x.ProductID).HeaderText("ID"); column.For(x => x.ProductName).HeaderText("Name"); column.For(x => x.CategoryID).HeaderText("Category") ; column.For(x => x.UnitPrice).HeaderText("Unit Price"); }); layout.For(x => x.Products2) .ForeignKey("CategoryID") .PrimaryKey("ProductID") .AutoGenerateColumns(false) .DataSourceUrl(Url.Action("BindProduct")) .Columns(column => { column.For(x => x.ProductID).HeaderText("ID"); column.For(x => x.ProductName).HeaderText("Name"); column.For(x => x.CategoryID).HeaderText("Category"); column.For(x => x.UnitPrice).HeaderText("Unit Price"); }); })
.ColumnLayouts(layout =>
{ layout.For(x => x.Products)
.ForeignKey("CategoryID")
.PrimaryKey("ProductID")
.AutoGenerateColumns(false)
.DataSourceUrl(Url.Action("BindProduct")
.Columns(column =>
{
column.For(x => x.ProductID).HeaderText("ID");
column.For(x => x.ProductName).HeaderText("Name");
column.For(x => x.CategoryID).HeaderText("Category")
; column.For(x => x.UnitPrice).HeaderText("Unit Price");
});
layout.For(x => x.Products2)
.DataSourceUrl(Url.Action("BindProduct"))
column.For(x => x.CategoryID).HeaderText("Category");
column.For(x => x.UnitPrice).HeaderText("Unit Price");
})
Please let me know if you have any further questions concerning this matter.
Appreciate your response, but I think I might not have been able to completely clarify what the problem is. As you know at the time of initializing the grid we specify the model type of the grid, so I set the model type as RoleRightsModel and set the grid as follows (Refer the model above in the question);@(Html.Infragistics().Grid<RoleRightsModel>() .ID("RoleRightsGrid") .PrimaryKey("Module") .AutoGenerateColumns(false) .AutoGenerateLayouts(false) .RenderCheckboxes(true) .Height("500px") .Width("700px") .Columns(column => { column.For(x => x.Module).HeaderText("Module").DataType ("string"); }) .ColumnLayouts(layouts => { layouts.For(x => x.ScreenType). AutoGenerateColumns(false). Columns(childcolumn => { childcolumn.For(x => x.ScreenTypeName).HeaderText ("Screen Type").DataType("string"); }); }) //Till the end of the gridThis gives me something like; Module+Module1+Module2On expanding any module i get; Module-Module1 ScreeType Reports+Module2 I want to go furthur down Reports and display all the screens asscoicated with it, in turn showing all the permissions given on that screen. Module-Module1 ScreeType -Reports -UserReport Add Edit Delete +FinancialReport +DI +RF +Module2The problem is that I cannot access the Screen and the Permission models in my grid, so that means I cant do something like;.Columns(column => { column.For(x => x.Module).HeaderText("Module").DataType ("string"); }) .ColumnLayouts(layouts => { layouts.For(x => x.ScreenType). AutoGenerateColumns(false). Columns(childcolumn => { childcolumn.For(x => x.ScreenTypeName).HeaderText ("Screen Type").DataType("string"); }); layouts.For(x => x.Screen). AutoGenerateColumns(false). Columns(childcolumn => { childcolumn.For(x => x.ScreenName).HeaderText ("Screen Name").DataType("string"); }); layouts.For(x => x.Permission). AutoGenerateColumns(false). Columns(childcolumn => { childcolumn.For(x => x.CanAdd).HeaderText ("Screen Type").DataType("string"); }); }) The data that gets passed to the view is something like this;[{"Module":"Security Manager","ScreenType":[{"ScreenTypeName":"RF","Screen":[{"ScreenName":"Dashboard","Permission":[{"CanAdd":true,"CanEdit":true,"CanDelete":false,"CanPrint":false}]},{"ScreenName":"Home","Permission":[{"CanAdd":false,"CanEdit":false,"CanDelete":true,"CanPrint":false}]}]}]},{"Module":"Sys Admin","ScreenType":[{"ScreenTypeName":"RF","Screen":[{"ScreenName":"Sys Admin Screen1","Permission":[{"CanAdd":false,"CanEdit":false,"CanDelete":true,"CanPrint":false}]},{"ScreenName":"Sys Admin Screen2","Permission":[{"CanAdd":false,"CanEdit":false,"CanDelete":true,"CanPrint":false}]}]}]}]I would appreciate any help in this regards
Thank you for the update. From what I can see from your model you would be able to display your Permission data as a child of the Screen so it would appear like the following:
1 RoleRightsModel 1(a) ScreenType 1(b) Screen 1(c) Permission
Currently the way you are setting your column layouts you have the ScreenType, Screen, and Permission all on the same level. If you want them to display on the same level you would have to modify the model to give the RoleRightsModel access to them directly. I recommend instead you setup the column layouts nested so that Screen appears under ScreenType and Permissions under Screen. In code this would look something like the following:
.Columns(column => { column.For(x => x.CategoryID).HeaderText("ID"); column.For(x => x.CategoryName).HeaderText("Name"); column.For(x => x.Description).HeaderText("Description"); }) .ColumnLayouts(layout => { layout.For(x => x.Products) .ForeignKey("CategoryID") .PrimaryKey("ProductID") .AutoGenerateColumns(false) .DataSourceUrl(Url.Action("BindProduct")) .ColumnLayouts(lay => { lay.For(z => z.ProdDesc) .ForeignKey("ProductID") .PrimaryKey("Number") .AutoGenerateColumns(false) .DataSourceUrl(Url.Action("BindProdDesc")) .Columns(column => { column.For(x => x.ProductID).HeaderText("ProductID"); column.For(x => x.Number).HeaderText("Number"); column.For(x => x.Desc).HeaderText("Desc"); }); }) .Columns(column => { column.For(x => x.ProductID).HeaderText("ID"); column.For(x => x.ProductName).HeaderText("Name"); column.For(x => x.CategoryID).HeaderText("Category"); column.For(x => x.UnitPrice).HeaderText("Unit Price"); }); })
column.For(x => x.CategoryID).HeaderText("ID");
column.For(x => x.CategoryName).HeaderText("Name");
column.For(x => x.Description).HeaderText("Description");
layout.For(x => x.Products)
.ColumnLayouts(lay =>
lay.For(z => z.ProdDesc)
.ForeignKey("ProductID")
.PrimaryKey("Number")
.DataSourceUrl(Url.Action("BindProdDesc"))
column.For(x => x.ProductID).HeaderText("ProductID");
column.For(x => x.Number).HeaderText("Number");
column.For(x => x.Desc).HeaderText("Desc");
Hi,
I came across another issue, I want to enable editing in the lowest level of the model i.e the screen model and update it.
I specify the UpdateUrl at the end of the grid like this;
UpdateUrl(Url.Action("UpdateRoleRights")).AutoCommit(true)
Now when I modify the screen model (which is the lowest level of the model) and the update method is called I don't seem to get anything from the transactions;
List<Transaction<RoleRightsModel>> transactions = gridModel.LoadTransactions<RoleRightsModel>(HttpContext.Request.Form["ig_transactions"]);
But if I edit the top most level of the mode i.e the RoleRightsModel, I can get the transactions. How can I access the updated rows from the lowest level of the hierarchy? Thanks in advance.
As this is a new issue I have created a case for this new issue. The case number for this is CAS-137660-J4X4H9. I will continue to support you concerning this matter though this case.