View Full Version : Comboboxes with javascript server side methods to generate the stores

30 Nov 2010, 4:42 AM

I'm working with a friend who provides me Javascript server side methods through REMObjects Server.

When I call a javascript server method provided by him it is returning me a JSON object by
querying a database.

I want to make a ComboBox with, let's say 'minChars : 4', so mode must be 'remote'... and after 4 chars
are typed the server side javascript method must be called and with the JSON returned I have to build
the store of the combobox.

Also the property 'fields' of the store can contain more or less fields
(different numbers and field names for different comboboxes). It's about a set of combobox filters
into a form for obtaining a report from a database.

I can't figure out how to solve this problem... with 'mode : remote' and not having a 'url' defined...
I have only server side methods which can be called.


30 Nov 2010, 5:08 AM
Configure the combobox store with a directFn (directly or inside the api read config) that does the actual request.

2 Dec 2010, 3:27 AM
This is what I have and I do not know how to make that combobox working:
- the javascript file with server side methods: WebReportsServerLibrary_intf.js is included in
index.html between <script></script>

I have also included:

<script type="text/javascript" src="js/yahoo.js"></script>
<script type="text/javascript" src="js/event.js"></script>
<script type="text/javascript" src="js/connection.js"></script>
<script type="text/javascript" src="js/event-delegate.js"></script>
<script type="text/javascript" src="js/json.js"></script>
<script type="text/javascript" src="js/WebReportsServerLibrary_intf.js"></script>

The following code shows one of my methods:

function WebReportsServerService(url){
this.url = url;

WebReportsServerService.prototype.GetListaCategorii = function(SessionID, __callback) {
var __message = {
"method" : "WebReportsServerService.GetListaCategorii",
"params" : {
"SessionID": SessionID
var __callbacks = null;
if (__callback) {
__callbacks = {
callback : __callback,
success : function (o) {
var __result = YAHOO.lang.JSON.parse(o.responseText);
if (__result.error)
if ((typeof this.callback == "object") && this.callback.failure)
} else {
if ((typeof this.callback == "object") && this.callback.failure)
failure : function (o) {
if ((typeof this.callback == "object") && this.callback.failure)
timeout : 30000
YAHOO.util.Connect.asyncRequest("POST", this.url, __callbacks, YAHOO.util.Lang.JSON.stringify(__message));

service = new WebReportsServerService("");

var storeFields = [{
name: 'Key'
name: 'Value'

var store = new Ext.data.DirectStore({
paramsAsHash: true
//,root: 'records'
//,totalProperty: 'total'
,directFn: service.GetListaCategorii(1, ?????
function(res){ ?????
return res; ??????
}) ?????
,fields: storeFields

var data = new Ext.form.ComboBox({
fieldLabel : 'qwerty'
,name : 'qwerty'
,emptyText : 'qwerty'
,mode : 'remote'
,minChars : 3
,loadingText: 'Querying...'
,triggerAction : 'all'
,width : 220
,store : store
,displayField : 'Key'
//,valueField : 'Value'
,width : elementWidth
,style : marginBottom
,hideTrigger : true
//,pageSize : 5

Server (WebReportsServer.exe) is started (it is a RemObjects server).

I'm working with above mentioned method and others for different components... it is working
but I do not know how to use: directFn (and or API)... what is returning that directFn method?