Base solution for your next web application
Open Closed

Jtable Create/Update parameters not binding #1277


User avatar
0
rajalla created

I am trying to use jtable createAction/updateAction methods to add/update records directly from the table.

actions: {
                                            listAction: {
                                                method: _campaignervice.getImportEmployeeDependants
                                            },
                                            updateAction: {
                                                method: _campaignervice.addUpdateImportListDependant
                                            },
                                            createAction: {
                                                method: _campaignervice.addUpdateImportListDependant
                                                    }

But when the call goes to the application service I noticed the values from the dialog form are not binding to the dto object. After further investigation I found below code from the abp.jtable.js which is being used to call the update method. Adding log statements to the code showed that the data posted from form (postdata) is a querystring and when it is not being converted JSON object properly.

return $.Deferred(function ($dfd) {

                    var input = $.extend({}, postData);
                    console.log(postData);
                    console.log(input);
                    originalUpdateAction.method(input)
                        .done(function (result) {
                            var jtableResult = { "Result": "OK" };
                            if (originalUpdateAction.returnsRecord) {
                                if (originalUpdateAction.recordField) {
                                    jtableResult.Record = result[originalUpdateAction.recordField];
                                } else {
                                    jtableResult.Record = result;
                                }
                            }

                            $dfd.resolve(jtableResult);
                        })
                        .fail(function (error) {
                            self._handlerForFailOnAbpRequest($dfd, error);
                        });
                });

Below is the console log [attachment=1:2bhvrp7r]Log.png[/attachment:2bhvrp7r]

So I tried converting the query string to JSON object as shown in the code below

return $.Deferred(function ($dfd) {

                    var input = $.extend({}, postData);
                    
                    console.log(postData);
                    input = $.parseJSON('{"' + postData.replace(/&/g, '","').replace(/=/g, '":"') + '"}');
                    console.log(input);
                    originalUpdateAction.method(input)
                        .done(function (result) {
                            var jtableResult = { "Result": "OK" };
                            if (originalUpdateAction.returnsRecord) {
                                if (originalUpdateAction.recordField) {
                                    jtableResult.Record = result[originalUpdateAction.recordField];
                                } else {
                                    jtableResult.Record = result;
                                }
                            }

                            $dfd.resolve(jtableResult);
                        })
                        .fail(function (error) {
                            self._handlerForFailOnAbpRequest($dfd, error);
                        });
                });

[attachment=0:2bhvrp7r]Log2.png[/attachment:2bhvrp7r]

And also the dto seems to be binding now. Just wondering why this is happening. Any help is appreciated.


3 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    Thank you for reporting this. Let us check it deeply. Have a nice day.

  • User Avatar
    0
    drenton created

    Is this fixed?

    Somehow, Save button does not close modal form.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    We didn't solve this issue yet. In the mean time, you can close the modal using this javascript code in your modified abp.jtable.js.

    self._$addRecordDiv.dialog("close");