Apr 04, 2021, 2:49 PM
Updating GridPanel Store
I had a hard time figuring out how to update store in 7.2 in controller.
Posting my solution. Hopefully it will save time for someone.
Posting my solution. Hopefully it will save time for someone.
List<Company> GetCompanies()
{
return new List<Company>
{
new Company {id = 1, name = "3m Co" },
new Company {id = 2, name = "Alcoa Inc" },
new Company {id = 3, name = "Altria Group Inc" },
new Company {id = 4, name = "American Express Company" },
};
}
public void OnGet()
{
this.GridData ??= GetCompanies().ToList<object>();
}
public IActionResult OnPostButtonSave_Click(int id, string name, string window)
{
List<Company> companies = GetCompanies();
companies.FirstOrDefault(c => c.id == id).name = name;
this.GetCmp<Window>(window).Close();
var gp = this.GetCmp<GridPanel>("gpOne");
gp.Store = new Store
{
Data = companies.ToList<object>(),
Fields = new List<DataField>
{
new NumberDataField { Name = "id" },
new DataField{ Name = "name" },
}
};
return this.Direct();
}
Last edited by VADIM; Apr 04, 2021 at 4:11 PM.
Reason: Update