Pregunta

Is it possible that listAction not call server function use AJAX , and the function will call to javascript function that return object ?

$('#ExecActDelays').jtable({
actions: {
listAction://get object from javascript no call server method
},
///...

can help me?

¿Fue útil?

Solución

thank i solve my proble, by edit jquery.jtable.js

my script:

function getObject(){
var result={};
result.Result="OK";
var array=[];
//...
{
array.push(new object...);
}
result.Records=array;
return result;
}

$('#ExecActDelays').jtable({
actions: {
listAction: getObject()
},

and in jquery.jtable.js i change

 self._ajax({
                    url: loadUrl,
                    data: self._lastPostData,
                    success: function (data) {
                        self._hideBusy();

                        //Show the error message if server returns error
                        if (data.Result != 'OK') {
                            self._showError(data.Message);
                            return;
                        }

                        //Re-generate table rows
                        self._removeAllRows('reloading');
                        self._addRecordsToTable(data.Records);

                        self._onRecordsLoaded(data);

                        //Call complete callback
                        if (completeCallback) {
                            completeCallback();
                        }
                    },
                    error: function () {
                        self._hideBusy();
                        self._showError(self.options.messages.serverCommunicationError);
                    }
                });
            }

to:(line 442)

 if (typeof loadUrl == "string") {
                self._ajax({
                    url: loadUrl,
                data: self._lastPostData,
                success: function (data) {
                    self._hideBusy();

                    //Show the error message if server returns error
                    if (data.Result != 'OK') {
                        self._showError(data.Message);
                        return;
                    }

                    //Re-generate table rows
                    self._removeAllRows('reloading');
                    self._addRecordsToTable(data.Records);

                    self._onRecordsLoaded(data);

                    //Call complete callback
                    if (completeCallback) {
                        completeCallback();
                    }
                },
                error: function () {
                    self._hideBusy();
                    self._showError(self.options.messages.serverCommunicationError);
                }
            });
        }
        else {//no from server method
            self._hideBusy();

            //Re-generate table rows
            self._removeAllRows('reloading');
            self._addRecordsToTable(loadUrl.Records);

            self._onRecordsLoaded(loadUrl);

            //Call complete callback
            if (completeCallback) {
                completeCallback();
            }
        }

my complete my jquery.jtable.js

Otros consejos

Try do this

function foo(){
   return object;// JSON object
}

$('#ExecActDelays').jtable({
actions: {
listAction: foo()
},
///...

OR try this too

var object = null;

function foo(){
   object = objectJSON;
}

$('#ExecActDelays').jtable({
actions: {
listAction: object
},
///...
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top