Hi,
I have created application .NET Core 3.x using razor pages. I am not sure how to binding works for the Igrid. Could you help me with binding works on this.
It's my cshtml.cs
[ActionName("GetRoles")]
public async Task OnGetAsync()
{
Role = await _context.Role
.Include(r => r.App).ToListAsync();
//GridModel gridModel = new GridModel();
//gridModel.ID = "grid1";
//gridModel.DataSource = _context.Role.AsQueryable();
//var paging = new GridPaging();
}
It's my razor page cshtml
@(Html.Infragistics()
.Grid(Model)
.ID("grid")
.Width("100%")
.Height("500px")
.PrimaryKey("RoleId")
.AutoGenerateColumns(false)
.AutoGenerateLayouts(false)
.Columns(column =>
column.For(x => x.RoleId).HeaderText("RoleId").Width("30%");
column.For(x => x.Description).HeaderText("Description").Width("30%");
})
.Features(features =>
features.Sorting().Type(OpType.Remote);
features.Paging().Type(OpType.Remote);
features.Filtering().Type(OpType.Remote);
features.Responsive().ColumnSettings(cs =>
cs.ColumnSetting().ColumnKey("RoleId").Classes("ui-hidden-phone");
cs.ColumnSetting().ColumnKey("Description").Classes("ui-hidden-phone ui-hidden-tablet");
});
.DataSourceUrl(Url.Action("GetRoles"))
.Render()
)
I tried to upload the project file (zip) but I don't see it here
Hello Anitha,
Binding the data to the grid by using .DataBind() is working on my side, without any errors. Could you please send me a small isolated sample, demonstrating the problem, which occurs by using .DataBind(). Having a working sample on my side, which I can debug, is going to be very helpful in finding the root cause of this behavior.
Thank you for your cooperation. Looking forward to hearing from you.
Regards,
Monika Kirkova,
Infragistics
Fixed the model null value error but the Infragistics grid is empty.
Thank you. I could be able to build the application without an issue but the grid is empty. I have see the role count is 12 from my context but the grid is empty when there’s .DataSourceUrl(Url.Action("GetRoles")) But returning error when using .DataBind()
After investigating this further, I determined that a model for the data could be created by adding a class to the project. The data for the model is defined in a method “GetRoles” in the Index.csthml.cs file and called in the “OnGet” method the following way:
public void OnGet()
Roles = GetRoles();
The model is bound to the igGrid as follows:
@(Html.Infragistics().Grid(Model.Roles.AsQueryable())
. . .
.DataBind()
Below I am attaching a sample, demonstrating the described behavior. Please test it on your side and let me know if you need any further information regarding this matter.
GridBindingCore.zip