PDA

View Full Version : [2.x] Ext.denkoo.fewQuery : Only One AJax Request=>many DataStore For loading COMBO



denkoo
24 Feb 2008, 1:59 AM
Hi,

I'm beginer on Ext Developpement, so My code is not perfect... sorry ))

This Ext can populate 10,20 or 30 combos on your form with only one AjaxQuery

A listener of AjaxRequest populate datastore of each COMBO.

Syntaxe for init the Ajax Request :


Ext.ux.denkoo.fewQuery.init(); // RAZ
// param in add method => add (idDS, "Task to ask data server","table bdd", Objet config transmit to server by POST)
Ext.ux.denkoo.fewQuery.add("society","listLoad","societyTable",{select :"idtiers, denomination", sort: "denomination", dir: "ASC"});
Ext.ux.denkoo.fewQuery.add("fonction","listLoad","fonctionTable",{select :"idtiersFonction", sort: "idtiersFonction", dir: "ASC"});
Ext.ux.denkoo.fewQuery.add("unite","listLoad","uniteTable",{select :"unite", sort: "unite", dir: "ASC"});
Ext.ux.denkoo.fewQuery.load();
and for each COMBO :


// param in getDs method => getDs (idDS)
store: Ext.ux.denkoo.fewQuery.getDs("society"),
Full online example :

http://213.251.166.160/~extjs/examples/fewQuery/fewquery.htm (http://213.251.166.160/%7Eextjs/examples/fewQuery/fewquery.htm)

Denkoo

jsakalos
24 Feb 2008, 6:30 AM
What happens if data in the underlying table changes - do I need to reload all stores or can I do it on per-store basis?

denkoo
24 Feb 2008, 8:14 AM
this Extension do :
0. with method this.init() => RAZ all data and dataStore
1. with method this.add(config)
=> collect all your requests... and affect on each an ID (idQuery)
=> create Ext.data.simpleStore with
data: this.myEmptyArray,
fields: Ext.decode(myConfigParamSELECT)
3. when you use method this.load()=>
=> generate only one requete => send it to server width Ajax
=> listener : load
+ responseText=>parse DATA=>populate this.myEmptyArray (in data.simpleStore)


Note: method this.getDs( idQuery )=>get Datastore width this idQuery

**********************************

So it's real Ext.data.simpleStore... you make all operation you doing with data.simpleStore habitualy ))

thanks for your Post and I will be please if you find some interest on this Extension when I see all your contribute ))

gratz

denkoo

denkoo
24 Feb 2008, 8:29 AM
When I populate my forms, randomely, Combo not display displayField, but valueField only. I refresh and sometime it's Ok, other time, not...

With this extension, I'm not constat this problem... It's the pleasant gift will make me great surprise )

force be with you )

jsakalos
24 Feb 2008, 9:03 AM
Well, I still don't know... If I use my server database in multiuser environment it can happen, and it happens, that another user changes data in the table that is used as row source for a combo.

Now, I need to reload the combo's store to get fresh data. The question is if I can reload only one store this extension keeps or if I need to reload all stores for all combos?

denkoo
24 Feb 2008, 4:36 PM
Sure, I have only "fields" and "data" parameter on my datastore, so you can't call load or reload on it !

So, i create method reload, for doing that (v0.2):

see the demo in online version :
http://213.251.166.160/~extjs/examples/fewQuery0.2/fewquery.htm (http://213.251.166.160/%7Eextjs/examples/fewQuery0.2/fewquery.htm)



Ext.ux.denkoo.fewQuery.reload("unite"); // for reloding dataStore 'unite'
Ext.ux.denkoo.fewQuery.reload("society", "fonction"); // for reloding dataStore 'society' and 'fonction' width only one request

roadmap:

=> choice type of datastore (grouping, json... with affected URL for reloading independantly [usefull on datagrid])
=> integrated link betwen 2 combos (listener metod + filter)

jsakalos
24 Feb 2008, 5:01 PM
Hmmm,

if there are only fields and data you can just create static arrays available on page load. Something like this:



<script type="text/javascript">
MyScope.store1data = {
fields:[ .... ]
,data:[ .... ]
};
MyScope.store2data = {
fields:[ .... ]
,data:[ .... ]
};
</script>
This solution is suitable only for static data (data that change very rarely) and for stores with only a few records. With this setup you need 0 extra client/server round trips and you can be sure that data is available before you try to combo.setValue().