Kendo UI Grid with datatype "json" for autosync entry
Posted by on January 15, 2014 16:26
Kendo UI Grid with datatype "json" for autosync entry
This blog help to you for updating your database using the editable list(i.e. kendo UI Grid)
If you need functionality which provide to save your data without “Save Button” then use “Kendo UI Grid with “AutoSync” functionality. This editor works as MS-Excel. Changes are getting saved automatically.
Following are the Kendo dependency, so first have to include all files.

Following steps are guiding that how to use Kendo UI Grid with AutoSync functionality.
-
1) Make one div tag. And give id to it(e.g. id="grid")
-
2) Now make javascript for “Kendo UI Grid”
-
Following piece of the code help you to read, add, edit and remove the data from database.
Here write your API path in “url” which handles these all functionality. So write the following javascript for datasource.
-

-
dataSource: It is used to display suggestions for the current value. And the above example is for the set.
dataSource as an existing kendo.data.DataSource instance.
-
dataSource-transport: This option describes the remote service configuration like HTTP headers, URL etc. It can also be used to implement custom data loading and saving.
-
dataSource-transport-parameterMap: It converts the request parameters to a format suitable for the remote service. By default the data source sends the parameter using JQuery’s conventions.
In parameterMap, You have to write “OPTIONS” instead of “OPTIONS.MODELS” and also in return statement you return “kendo.stringify(options)” instead of “{models: kendo.stringify(options.models)}”.
-
3) The other options are set for editor. Write your column names into models.
Give id which is your primary key. And all column name into fields.
-
Following piece of code indicate you that what to write.
-

-
AutoSync: By default it is false. But if you set to true the data source would automatically save any changed data items using sync method.
-
Batch: If set to true the data source will batch CRUD operation requests. It means if updating any two data item would cause one HTTP request instead of two.
-
Fields: Define primary key and all column names which are you want in editor.
-
This example is add and update the database using Autosync option. So if you want to update / add data, when you change control from one column to other column then save your data in back end automatically.
-
Here not exists any Save Button to save data.
-
Here we take different data types column. Number, String, Boolean.
-
4) Now simply define all attribute which help to make grid user-friendly.
Into columns attribute,write all field name which want to display.
Reference:
Kendo UI Grid