PDA

View Full Version : [CLOSED] How to use data from database in "Combo with Templates and Ajax" example



avante
Jan 14, 2013, 9:37 PM
Hi,

I am needing to use the component having the "autofill" functionality in this example: http://examples2.ext.net/#/Form/ComboBox/Custom_Search/

How can I do this filling the store of combobox with an database and using the text that user are writting in my query?

I really need to use an handler like in example or can I use a method in server-side code of the page, that be called every time that user write one letter?

I appreciate your attention.

Baidaly
Jan 14, 2013, 11:58 PM
Hello!

You can use DirectMethod to send data from DB to Client. Everything should be the same you just have to replace store's Proxy. Example: http://examples2.ext.net/#/GridPanel/ArrayGrid/PageProxy_with_DirectMethod/

avante
Jan 15, 2013, 4:40 AM

Daniil
Jan 15, 2013, 9:49 AM
Hello @avante,

There are two problems.

1. Referencing a DirectMethod within a user control.

By default, it is

App.direct.UserControlID.DirectMethodName

So, this is wrong:

DirectFn="App.direct.BindData"

You can set up

[DirectMethod(IDAlias="UC")]
public object BindData() { ... }
and use

DirectFn="App.direct.UC.BindData"

See also:
http://examples2.ext.net/#/Events/DirectMethods/ID_Mode/

We also investigate a possibility to get this working.

DirectFn="#{DirectMethods}.BindData"

2. Using a static DirectMethod within a user control.

Unfortunately, it can be defined on the page level only. So, please remove "static".

Here are some more details.
http://forums.ext.net/showthread.php?12613&p=51877&viewfull=1#post51877

Daniil
Jan 15, 2013, 1:59 PM
We also investigate a possibility to get this working.

DirectFn="#{DirectMethods}.BindData"


This should work after updating from SVN (trunk).

avante
Jan 15, 2013, 9:47 PM

Baidaly
Jan 15, 2013, 11:04 PM
1) How can I filter the results that will appear in the combobox with the text that is written by the user, in the moment that he write?

2) What I need to do for the paging works? At this moment, all results of my research are appearing without respecting paging.



Please, take a look at this example http://examples2.ext.net/#/GridPanel/Paging_and_Sorting/DirectMethod/ . Requested query you can find in ExtraParams.



[DirectMethod(IDAlias = "UC")]
public object BindData(string action, Dictionary<string, object> extraParams)
{
StoreRequestParameters prms = new StoreRequestParameters(extraParams);
string query = (string)extraParams["query"];

return Data;
}

avante
Jan 17, 2013, 7:51 AM

Daniil
Jan 17, 2013, 8:39 AM
Setting these options for the Store appears to be helpful.

AutoLoad="true" IsPagingStore="true" PageSize="2"

Though it is a tricky scenario to load data on the Change event.

If you need to load data remotely on typing and organize paging, configuring the Store with a Proxy is the best solution.

avante
Jan 17, 2013, 5:47 PM
Very good Daniil, it works now.

You can close this thread.

Thank you very much.