jQWidgets Forums
jQuery UI Widgets › Forums › Grid › After updaterow saved clientside, I want to update the row client-side …
Tagged: angular grid, client side, commit, grid, jquery grid, jqxgrid, row, update, updatebounddata, updaterow
This topic contains 7 replies, has 2 voices, and was last updated by Dimitar 9 years, 7 months ago.
-
Author
-
August 24, 2015 at 8:44 pm After updaterow saved clientside, I want to update the row client-side … #75130
After an update is made, I am having my script return the row values (after the update):
“{“success”:true,”content”:{“id”:”96″,”name”:””,”annual_income”:”8787.00″,”job_title”:””,”stated_credit_score”:”9976″,”experian_credit_score”:null,”equifax_credit_score”:null,”transunion_credit_score”:null,”credit_report_source”:””,”is_cosigner”:”0″,”lastUpdated”:null}}”I am planning on adding a timestamp column so I need the row on the client-side to update with the new values from the DB:
I tried: commit(true, rowid, data.content); and commit(true, data.content) but I can’t get the client-side row to update with fresh values from the DB after the update has finished (it does update the DB but I need to then update the client-side row with the actual values from the database)updaterow: function (rowid, rowdata, commit) { $.ajax({ dataType: 'json', url: '/g/handler.php?h='+handlerName+'&masterId=' + masterID, data: "update=true&id=" + rowid + '&' + $.param(rowdata), success: function (data, status, xhr) { if('success' in data) { if (data.success==true) { //alert(rowid); commit(true, rowid, data.content); } else { commit(false); alert('Error Updating Record'); } } else { commit(false); alert('Unexpected Response From Server'); } }, error: function(jqXHR, textStatus, errorThrown) { commit(false); alert('Error Commmunicating With Server'); } }); }
Please advise, thanks.
August 25, 2015 at 7:28 am After updaterow saved clientside, I want to update the row client-side … #75138Hello markm123,
Are you sure
commit(true, rowid, data.content);
is actually called? If it is and the client-side row is still not updated, then please try calling onlycommit(true);
. You can also try calling the method updatebounddata afterwards. If there are any errors thrown in your browser’s console while running your code, please share what they are.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/August 25, 2015 at 6:03 pm After updaterow saved clientside, I want to update the row client-side … #75155Yes because without the commit, nothing happends on the client-side… I tried:
if (data.success==true) {
commit(true);
$(‘#’+ref).jqxGrid(‘updatebounddata’, data.content);
}data JSON response below (contains all rows as required per updateboundata):
{“success”:true,”content”:[{“id”:”96″,”name”:””,”annual_income”:”8787.00″,”job_title”:””,”stated_credit_score”:”9976″,”experian_credit_score”:null,”equifax_credit_score”:null,”transunion_credit_score”:null,”credit_report_source”:””,”is_cosigner”:”0″,”lastUpdated”:null},{“id”:”97″,”name”:””,”annual_income”:”88.00″,”job_title”:””,”stated_credit_score”:””,”experian_credit_score”:null,”equifax_credit_score”:null,”transunion_credit_score”:null,”credit_report_source”:””,”is_cosigner”:”1″,”lastUpdated”:null}]}However another call is being made to the server to get updated data …
Is there anyway to update the local data from the JSON response given after an update?
I should also note that the rowid is my databases unique ID (I have it specified in the data source id: ‘id’,).
Perhaps commit needs some other type of rowid or does it know that the ID I am referring to is the one my server assigned it…
August 25, 2015 at 7:25 pm After updaterow saved clientside, I want to update the row client-side … #75158Correction: I know commit(false) works because the client-side row is reverted back to previous changes upon
updaterow
when that statement is present. I don’t know that commit(true) is being called as nothing on the client-side indicates it (Given the fact that the local row is not updating from server-side data after updaterow)I am receiving no errors however…
August 26, 2015 at 6:10 am After updaterow saved clientside, I want to update the row client-side … #75170Hi markm123,
In the updaterow callback, commit “knows” which row you have updated. The second parameter of commit is relevant only in the addrow callback.
You can test if the
commit(true);
line is called with an alert or by placing a breakpoint (in Microsoft Visual Studio or Google Chrome’s Developer tools for example). If everything is correctly set up,commit(true)
should update the client-side row without any additional code.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/August 27, 2015 at 2:47 pm After updaterow saved clientside, I want to update the row client-side … #75215Yes, commit(true) is being called but I still cannot get the local-row to update with fresh data from the server without it making a second call…
The only solution I can possibly see is:
commit(true); $.each(data.content, function(k, v) { if ($('#'+ref).jqxGrid('iscolumnvisible', k)) { $('#'+ref).jqxGrid('setcellvalue', rowindex, k, v); } });
Are you sure that the commit(..) function within the updaterow function supports updating the local row with JSON supplied in 2nd parameter if present?
Example:
updaterow: function (rowid, rowdata, commit) {
var newdata = {full_name: “abc”};
commit(true, newdata);
}And as a result, the column in that local row would be updated with “abc” regardless with what rowdata contains..
August 27, 2015 at 3:18 pm After updaterow saved clientside, I want to update the row client-side … #75217Actually, upon further testing … setcellvalue is re-invoking the updaterow function (a variable would have to passed/updated to tell it not to update)
August 28, 2015 at 5:19 am After updaterow saved clientside, I want to update the row client-side … #75228Hi markm123,
In updaterow, commit should be passed only one boolean argument with a value of true or false. If the it is true, the client-side row will be updated. A second argument can be passed to commit only in the addrow callback. I think your code should simply be:
success: function(data, status, xhr) { if ('success' in data) { if (data.success == true) { commit(true); } else { commit(false); alert('Error Updating Record'); } } else { commit(false); alert('Unexpected Response From Server'); } },
Our tutorial Build CRUD Web App with jqxGrid using PHP and MySQL shows a working implementation of the three server synchronisation callback functions. Please check it out.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.