Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

dxDataGrid - How to implement a custom store with CRUD operations (SQLite)

$
0
0

The dxDataGrid binding using a CustomStore help topic and the A custom data source does not apply paging, filtering, sorting and grouping article describe how to implement a custom data source that loads data for a dxDataGrid . 

This example demonstrates how to make a custom store that works with a SQLite data source. For this purpose, the SQLite PhoneGap plugin is used. Note how the custom store's insertupdate and remove methods are implemented to use the plugin's API. Each of these methods will be called automatically by the widget.  When a method is called, we need to execute a corresponding SQL query and pass the required parameters. Note that in order to work with the database, it is necessary to initialize it in the "deviceready" event handler:

[JScript]
//index.js $(document).on("deviceready", function(){... window.db = window.sqlitePlugin.openDatabase({ name: "DB"});});

Note how the deferred object resolves the amount of affected rows in each method and the reject function receives the exception message. This allows displaying the query execution exception in the grid's error row.

The example contains a ready-to-use package file for Android, so you can install and test it right away. Any modification or building the package for iOS will require going through steps described in Packaging.

See also:
Deferred Object
How to implement CRUD operations with a DataSource
dxDataGrid - How to implement a custom store with CRUD operations


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>