Data Providers
Dynamic Data
Deleting Dynamic Data
5min
with the ability to create and update data, you must be able to delete data that is no longer needed this example shows how to delete a single row of data and then how to delete multiple rows of data from a {{jig}} datasources, jigs, component & actions default jigx is the database where the {{dynamicdata}} table is defined sqlite docid\ glsk3v8ibeix zmscfstd datasource calls the {{dynamicdata}} provider, using an sql query to return the data jig list docid 5uifnxycbeewhizctnjqm is the type of {{jig}} used to list the data with a swipeable left action that uses the {{dynamicdata}} provider's delete method examples and code snippets examples and code snippets delete a single data record using execute entity record deleted from table delete single record jigx title list type jig list icon delete 2 header type component jig header options height medium children type component image options source uri https //images unsplash com/photo 1531545514256 b1400bc00f31?q=80\&w=1374\&auto=format\&fit=crop\&ixlib=rb 4 0 3\&ixid=m3wxmja3fdb8mhxwag90by1wywdlfhx8fgvufdb8fhx8fa%3d%3d onfocus type action action list options issequential true actions \ type action sync entities options provider data provider dynamic entities \ default/employee datasources employee list \# the sqlite datasource calls the dynamic data provider, writing a sql query returns the data from the provider to the jig type datasource sqlite options provider data provider dynamic entities \ default/employee query select id, '$ first name', '$ last name', '$ job title', '$ email', '$ start date', '$ department', '$ contact' from \[default/employee] \# reference the datasource to be used in the list data =@ctx datasources employee list item type component list item options title =(@ctx current item first name & ' ' & @ctx current item last name) subtitle =@ctx current item job title swipeable right \ label delete icon delete 2 color negative onpress \# execute the delete method of the dynamic data provider and use the id of the item swiped to identify the data that must be deleted type action execute entity options provider data provider dynamic entity default/employee method delete data id =@ctx current item id onsuccess type action go back default jigx tables employee null index jigx name employees title employees category business tabs home jigid delete single record icon home apps logo deleting multiple data records using execute entities to delete all employees (multiple data records) in the {{dynamicdata}} table use the action execute entities action with an expression that as shown below this will delete all records in the table when the delete all employees button is pressed delete multiple records all records deleted from table delete multiple records jigx title list type jig list icon delete header type component jig header options height medium children type component image options source uri https //images unsplash com/photo 1531545514256 b1400bc00f31?q=80\&w=1374\&auto=format\&fit=crop\&ixlib=rb 4 0 3\&ixid=m3wxmja3fdb8mhxwag90by1wywdlfhx8fgvufdb8fhx8fa%3d%3d onfocus type action action list options issequential true actions \ type action sync entities options provider data provider dynamic entities \ default/employee datasources employee list \# the sqlite datasource calls the dynamic data provider, writing a sql query returns the data from the provider to the jig type datasource sqlite options provider data provider dynamic \# specify the table in dynamic data that you want to work with entities \ default/employee query select id, '$ first name', '$ last name', '$ job title', '$ email', '$ start date', '$ department', '$ contact' from \[default/employee] data =@ctx datasources employee list item type component list item options title =(@ctx current item first name & ' ' & @ctx current item last name) subtitle =@ctx current item job title swipeable right \ label delete icon delete 2 color negative onpress type action execute entity options provider data provider dynamic entity default/employee method delete data id =@ctx current item id onsuccess type action go back \# add a button to the list to detete all records actions \ children \ type action confirm options style isdanger true title delete all employees isconfirmedautomatically false onconfirmed type action execute entities options \# execute the delete method of the dynamic data provider, use the datasource in the expression to specific all ids to delete provider data provider dynamic entity default/employee method delete data =@ctx datasources employee list {"id" \ id}\[] onsuccess type action go back \# deleting all data is irreversible, use a modal to confirm the delete before actually executing the delete modal title are you sure you want to delete all? default jigx tables employee null index jigx name employees title employees category business tabs home jigid delete multiple records icon home apps logo