PDA

View Full Version : [CLOSED] What are the differences between .DataSource and .LoadData()



sisa
Oct 28, 2014, 2:33 PM
Hi all

Could someone give a brief explanation to me ? What are the differences between



MyStore.dataSource = someKindOfArray;
MyStore.dataBind();


and



MyStore.loadData(someKindOfArray);


Both seem to work ?!

Kind Regards
Peter

Daniil
Oct 28, 2014, 3:24 PM
Hi Peter,

A Store's LoadData method is a wrapper for the JavaScript loadData method.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.data.Store-method-loadData

The key point is "Using this method is great if the data is in the correct format already".

So, the data passed to a .LoadData() call goes directly to the Store bypassing a Store's Model.

If you use a Store's DataSource then the data is serialized according to the Store's Model. Also all client side transformations like ModelField's Mapping and Convert are done.

sisa
Oct 28, 2014, 4:31 PM
Thank's Daniil for this...

Is it possible that the 'loadData' triggers the Prepare Command and the 'dataSource/dataBind' doesn't ?
I had this while updating an exsting store...

Peter

Daniil
Oct 28, 2014, 5:12 PM
I would say they both should trigger a PrepareCommand, because they both should trigger refreshing of GridPanel. In other words when a GridPanel refreshes, it triggers PrepareCommand handlers.

sisa
Oct 29, 2014, 3:26 PM
Ok, thank you I understand now :-)

Peter