Hello,
I'm testing the MVC Hierarchical grid with the following code. I can't edit the child rows and I can't select one child row, it selects all the child row.
@(Html.Infragistics() .Grid(Model) .ID("igGrid") .AutoGenerateColumns(false) .PrimaryKey("ID") .Features(f => { f.Updating().EditMode(GridEditMode.Row); }) .UpdateUrl(Url.Action("CfgCatalogsSaveData")) .Columns(column => { column.For(x => x.ID).HeaderText("ID"); column.For(x => x.Name).HeaderText("Name"); }) .ColumnLayouts(layouts => { layouts.For(x => x.CfgCatalogItems) .PrimaryKey("ID") .AutoGenerateColumns(false) .AutoCommit(true) .Columns(childcols1 => { childcols1.For(x => x.ChoiceValue).HeaderText("Valeur"); childcols1.For(x => x.Label).HeaderText("Texte"); childcols1.For(x => x.Congruent).HeaderText("Compliant"); }) .Features(g => { g.Updating().EditMode(GridEditMode.Row); }) ; })
.DataBind() .Render())
Best regards,
Alain
Hello Alain,
Both issues are most likely related to the fact you are not defining the ID column for the child layout but still set it as a primary key. Updating requires that there is a correct and unique primary key defined available for the data source you are editing. Selection would select all rows that have the same PK and since the PK column is not defined all values for it will be 'null' causing the behavior you are experiencing.
I hope this helps! Please, let me know if you have any other questions or concerns!
Stamen Stoychev
Hello Stamen,
It works, thank you.
But I have another problem. I save the data to the server with UpdateUrl(...), but the data added or changed in the children are never send to the server. It works properly for the parent.
public ActionResult CfgCatalogsSaveData() { GridModel gridModel = new GridModel(); List<Transaction> transactions = gridModel.LoadTransactions(HttpContext.Request.Form["ig_transactions"]);//List<Transaction> transactions2 = gridModel.LoadTransactions(HttpContext.Request.Form["ig_transactions"]);
foreach (Transaction t in transactions) { if (t.type == "newrow") { //model.Add(t.row); } else if (t.type == "deleterow") { //model.Remove(model.Find(Convert.ToInt32(t.rowId))); } else if (t.type == "row") { //CfgUnit o = model.Find(Convert.ToInt32(t.rowId)); //o.Name = t.row.Name; //o.Note = t.row.Note; } }
JsonResult result = new JsonResult(); Dictionary response = new Dictionary(); response.Add("Success", true); result.Data = response; return result; }
I haven't found an example, could you help me ?