VB Data binding from local data with edits persisted on the server

I'm able to populate a grid from my model with this code


@Html.EJS().Grid(Of ts_Tenancy)("Tenancy").DataSource(Model.tenancies).Columns(
                                                                                                                                                             Sub(col)
                                                                                                                                                                 col.Field("tncid").AllowEditing(False).HeaderText("tncID").IsPrimaryKey(true).Width(20).Add()
                                                                                                                                                                 col.Field("tnccot").EditType(EditingType.Datepicker).HeaderText("COT").Format("dd/MM/yyyy").Type("Date").Width(25).Add()
                                                                                                                                                                 col.Field("tnceot").EditType(EditingType.Datepicker).HeaderText("EOT").Format("dd/MM/yyyy").Type("Date").Width(20).Add()
                                                                                                                                                                                                                                                                                                                             End Sub).Render()


However, I want to be able to enable editing and do a CRUD update to post data back to the server.

I cant get data to populate in the grid.

dim tenanciesJSON as string = Newtonsoft.Json.JsonConvert.SerializeObject(Model.tenancies)

@Html.EJS().Grid(Of ts_Tenancy)("Tenancy").DataSource(Sub(ds) ds.Jsonp(tenanciesJSON).UpdateUrl("/Home/Update")).EditSettings(Sub(edit) edit.AllowEditing(True).AllowAdding(True)).Columns(
                                                Sub(col)
                                                    col.Field("tncid").AllowEditing(False).HeaderText("tncID").Width(20).Add()
                                                    col.Field("tnccot").EditType(EditingType.Datepicker).HeaderText("COT").Format("dd/MM/yyyy").Type("Date").Width(25).Add()
                                                    col.Field("tnceot").EditType(EditingType.Datepicker).HeaderText("EOT").Format("dd/MM/yyyy").Type("Date").Width(20).Add()
                                                End Sub).Toolbar({"Add", "Edit", "Update"}).Render()


I keep getting "No records to display"

tenanciesJSON is " [{"tncid":11441,"tnccot":"2013-12-23T00:00:00","tnceot":null}]"


Thanks


Ross


1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team April 1, 2024 06:17 PM UTC

Hi Ross,


  Greetings from Syncfusion support.


  Based on your query, you want to perform crud operation in the server side and persist the data in the server side. Based on the code example provided, you are getting the data from the Model, and you are using the UpdateUrl method to update the data to the grid. We suggest you use the RemoteSaveAdaptor for data binding. Please refer the below documentation for more details on the remote save adaptor. Please refer the below documentation for more details on binding the data from the server using RemoteSaveAdaptor.


Documentation: https://ej2.syncfusion.com/aspnetmvc/documentation/grid/data-binding/remote-data#remote-save-adaptor


Regards,

Joseph I.


Loader.
Up arrow icon