BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
I have MVC member search app that runs as a partial view inside a CMS system (search by name, city, state, zip fields). On form submit, what is the best way to bind that data to the grid and then also having paging, sorting, etc enabled? Do you have an sample or example I can view?
Many thanks!
I believe I have a some-what working version... One issue though is I'm trying to pass a search query parameter back to a custom paging action in the controller and the controller is indeed getting called but the param is not getting passed (always null). Grid sample below. Any ideas on what I'm missing? Many thanks!
@(Html.Syncfusion().Grid<Member>("MemberGrid")
.Datasource(Model.SearchResults)
.ShowCaption(false)
.ShowRowHeader(false)
.EnablePaging()
.PageSettings(settings => settings.PageSize(5).PageCount(10))
.QueryParam("?qs_query=" + Model.SearchString) // Query params
.Mappers(map =>
{
map.Action("SearchPaging"); //used as the mapper for Grid Post action for Paging/Sorting, etc.
})
.Column(cols =>
{
cols.Add("MemberTemplate").HeaderText("Member Results");
})
.QueryCellInfo(cell =>
{
if (cell.TableCellType == GridTableCellType.AlternateRecordFieldCell || cell.TableCellType == GridTableCellType.RecordFieldCell)
{
if (cell.Column.MappingName == "MemberTemplate")
{
cell.Text = "<ul class=\"member-search-results\">" + Html.Partial("DisplayTemplates/MemberTemplate", cell.Data) + "</ul>";
}
}
})
)
I've believe I have it figured out... Instead of attempting to pass it through as a QueryParam value, I need to pass it to Controller as a route value... makes sense...
@(Html.Syncfusion().Grid<Member>("MemberGrid")
.Datasource(Model.SearchResults)
.ShowCaption(false)
.ShowRowHeader(false)
.EnablePaging()
.PageSettings(settings => settings.PageSize(5).PageCount(10))
.Mappers(map =>
{
map.Action("SearchPaging", new { SearchString = Model.SearchString }); //used as the mapper for Grid Post action for Paging/Sorting, etc.
})
.Column(cols =>
{
cols.Add("MemberTemplate").HeaderText("Member Results");
})
.QueryCellInfo(cell =>
{
if (cell.TableCellType == GridTableCellType.AlternateRecordFieldCell || cell.TableCellType == GridTableCellType.RecordFieldCell)
{
if (cell.Column.MappingName == "MemberTemplate")
{
cell.Text = "<ul class=\"member-search-results\">" + Html.Partial("DisplayTemplates/MemberTemplate", cell.Data) + "</ul>";
}
}
})
)
Hi
John,
Thanks
for your interest in Syncfusion products.
We
are glad to hear that the issue has been resolved in your side. Please let us
know if you have any other queries. We will be happy to assist you.
Please
let us know if you need any further assistance.
Regards,
Abdul
Matin M
Say I want to pass the Model back to the paging method... how can I do that?
@(Html.Syncfusion().Grid<ncba.CRM.xweb.custom.MemberObject>("MembershipDirectoryGrid")
.Datasource(Model.SearchResults)
.ShowCaption(false)
.ShowRowHeader(false)
.EnablePaging()
.AutoFormat(Skins.Marble)
.PageSettings(settings => settings.PageSize(10).PageCount(10))
.Mappers(map =>
{
map.Action("MembershipDirectorySearchPaging", Model ); //used as the mapper for Grid Post action for Paging/Sorting, etc.
})
)
Hi
John,
Thanks
for your update.
We
are glad to let you know that your requirement can be achieved by Serializing
the Model data and pass the Serialized Model data to the Mapper action used for
Paging/Sorting. Please refer the below code snippet.
[CSHTML]
@(Html.Syncfusion().Grid<PassModel.Models.Student>("GenericListGrid")
.Datasource(Model)
.Caption("Student
Details")
.EnableSorting() /*Sorting Enabled*/
.EnablePaging() /*Paging Enabled*/
.Column(cols =>
{
cols.Add(c => c.UniversityCode).HeaderText("University Code").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(130);
cols.Add(c => c.Title).HeaderText("Title").Width(200);
cols.Add(c => c.Duration).HeaderText("Duration").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(120);
cols.Add(c => c.CourseFees).HeaderText("Course Fees").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Format("{0:C}").Width(120);
cols.Add(c => c.CGPA).HeaderText("CGPA").TextAlign(Syncfusion.Mvc.Grid.TextAlignment.Right).Width(180).Format("{0:P}");
})
.Mappers(map => { map.Action("GridFeatures", new {
modelData = Newtonsoft.Json.JsonConvert.SerializeObject(Model)
}); }) //Serialize the Model data
)
We
have also created a simple sample for your requirement and the same can be
downloaded from the link below. Please use the sample and get back to us if you
have any other queries.
Please
let us know if you need any further assistance.
Regards,
Abdul
Matin M