jQuery UI Widgets › Forums › Grid › JQXGrid is not calling the serverside update function
Tagged: datagrid, datagrid control, jquery grid control, jqxgrid
This topic contains 4 replies, has 2 voices, and was last updated by Peter Stoev 13 years, 3 months ago.
-
Author
-
hi ..
i have problem with getting the updated row in serverside code
im seeing the data in the grid correctly..
here is my html&javascript code … that is functioning correctly<script type="text/javascript"> $(document).ready(function () { source = { datatype: "xml", datafields: [ { name: 'FullName' }, { name: 'Tel' } ], async: false, record: 'Table', url: 'DataGrid.aspx/GetCustomers', updaterow: function (rowid, rowdata) { var data = $.param(rowdata); $.ajax ({ dataType: 'json', url: 'DataGrid.aspx/UpdateCustomer', data: data, success: function (data, status, xhr) { // update command is executed. } }); } }; var dataAdapter = new $.jqx.dataAdapter(source, { contentType: 'application/json; charset=utf-8' } ); $("#jqxgrid").jqxGrid({ theme: 'ui-start', source: dataAdapter, editable: true, editmode: 'click', columns: [ { text: 'Tel', dataField: 'Tel' }, { text: 'FullName', dataField: 'FullName' } ] }); $("#jqxgrid").bind('cellendedit', function (event) { var args = event.args; var rowindex = args.rowindex; var rowid = args.rowindex; var row = $("#jqxgrid").jqxGrid('getrowdata', rowindex); var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; if (rowindex >= 0 && rowindex < rowscount) { if (args.datafield == "Tel") { row.Tel = args.value }; if (args.datafield == "FullName") { row.FullName = args.value }; $("#jqxgrid").jqxGrid('updaterow', rowid, row); } }); }); </script>
And my c# code is :
[WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Xml)] public static string GetCustomers() { System.IO.StringWriter writer = new System.IO.StringWriter(); BusinessRules.Members.GetAllForJQX().WriteXml(writer); return writer.ToString(); } [WebMethod] [ScriptMethod(UseHttpGet = true)] public static void UpdateCustomer(DataRow row) { }i have used breakpoint to see if the UpdateCostumer function is getting executed or not …
and unfortuntely its not getting executed by the javascript codes…any help will be appreciated ..
no one knows the answer ?
Hi mohamadz14,
Unfortunately, I don’t know why this code:
$.ajax ({ dataType: 'json', url: 'DataGrid.aspx/UpdateCustomer', data: data, success: function (data, status, xhr) { // update command is executed. } });is not calling your UpdateCustomer method. Check whether you use jQuery 1.6+ version, because the default one coming with Visual Studio is 1.4.2 and the ajax function may work in a different way in it. Also if you are using ASP .NET, you should may be set the ajax function’s contentType to:
contentType: 'application/json; charset=utf-8',Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comhi and thanks for reply
im using jquery 1.8.2im using contenttype tag here in the code :
var dataAdapter = new $.jqx.dataAdapter(source,{ contentType: 'application/json; charset=utf-8' });should i use it anywhere else ?
and im using this code abbove the updateCustomer Function
[WebMethod][ScriptMethod(UseHttpGet = true)]
is it correct ?
Hi mohamadz14,
I suppose that you need to set it in the Ajax function, too i.e where you actually try to update.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.