jQWidgets Forums
jQuery UI Widgets › Forums › Grid › PHP edit grid question help
Tagged: PHP edit grid
This topic contains 4 replies, has 2 voices, and was last updated by Inverse 11 years, 2 months ago.
-
Author
-
I want to be able ajax without refreshing edit
Page does not reforming
help me..
$(document).ready(function () { // prepare the data var theme = 'classic'; var getLocalization = function () { var localizationobj = {}; localizationobj.pagergotopagestring = "1"; localizationobj.pagershowrowsstring = "2"; localizationobj.pagerrangestring = " 3 "; localizationobj.pagernextbuttonstring = "voriger"; localizationobj.pagerpreviousbuttonstring = "nächster"; localizationobj.sortascendingstring = "Sortiere aufsteigend"; localizationobj.sortdescendingstring = "Sortiere absteigend"; localizationobj.sortremovestring = "Entferne Sortierung"; localizationobj.firstDay = 1; localizationobj.percentsymbol = "%"; localizationobj.currencysymbol = "€"; localizationobj.currencysymbolposition = "after"; localizationobj.decimalseparator = "."; localizationobj.thousandsseparator = ","; var days = { // full day names names: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"], // abbreviated day names namesAbbr: ["Sonn", "Mon", "Dien", "Mitt", "Donn", "Fre", "Sams"], // shortest day names namesShort: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"] }; localizationobj.days = days; var months = { // full month names (13 months for lunar calendards -- 13th month should be "" if not lunar) names: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember", ""], // abbreviated month names namesAbbr: ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dez", ""] }; var patterns = { d: "dd.MM.yyyy", D: "dddd, d. MMMM yyyy", t: "HH:mm", T: "HH:mm:ss", f: "dddd, d. MMMM yyyy HH:mm", F: "dddd, d. MMMM yyyy HH:mm:ss", M: "dd MMMM", Y: "MMMM yyyy" } localizationobj.patterns = patterns; localizationobj.months = months; localizationobj.todaystring = "Heute"; localizationobj.clearstring = "Löschen"; return localizationobj; } var source = { datatype: "json", cache: false, datafields: [ { name: 'id', type: 'string'}, { name: 'status', type: 'string'}, ], id: 'id', url: 'data.php', cache: false, filter: function() { // update the grid and send a request to the server. $("#jqxgrid").jqxGrid('updatebounddata', 'filter'); }, sort: function() { // update the grid and send a request to the server. $("#jqxgrid").jqxGrid('updatebounddata', 'sort'); }, root: 'Rows', beforeprocessing: function(data) { source.totalrecords = data[0].TotalRows; } }; var dataadapter = new $.jqx.dataAdapter(source, { loadError: function(xhr, status, error) { alert(error); } } ); // initialize jqxGrid var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 520, source: dataadapter, theme: theme, selectionmode: 'multiplerows', pageable: true, filterable: true, sortable: true, virtualmode: true, showfilterrow: true, autoheight: true, localization: getLocalization(), rendergridrows: function(obj) { return obj.data; }, columns: [ { text: 'id', datafield: 'id', width: 80 }, { text: 'status', datafield: 'status', width: 50, }, ] }); $("#up").on('click', function () { var selectedrowindex = $("#jqxgrid").jqxGrid('getselectedrowindex'); var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount; if (selectedrowindex >= 0 && selectedrowindex < rowscount) { var row = $("#jqxgrid").jqxGrid('getrowdata', selectedrowindex); $.ajax({ dataType: 'json', url: 'select.php', data: 'id='+row.id+'&status='+row.status, cache: false, }); } }); }); </script> <input id="up" type="button" value="check" />
PHP code
<?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $dbname = 'pos'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection'); mysql_query("SET NAMES 'utf8'"); mysql_select_db($dbname); if($_GET['status'] == 0){ mysql_free_result($result); $sql = "update into_goods set status =1 where <code>id</code>='".$_GET['id']."'"; $result = mysql_query($sql) or die('MySQL query error'); } else { mysql_free_result($result); $sql = "update into_goods set status =0 where <code>id</code>='".$_GET['id']."'"; $result = mysql_query($sql) or die('MySQL query error'); } ?>
Hi Roberto,
I spotted a syntax error in your code: cache: false, – the ‘,’ should be removed, because cache: false is the last item.
Another syntax error is: { text: ‘status’, datafield: ‘status’, width: 50, },. The ‘,’ after 50 and after ‘}’ should be removed.Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThank you Peter Stoev
But I want to ajax web no Refresh
I now code is Refresh
Please help me~
Hi Inverse,
To perform a new Ajax request using the same dataAdapter, use the jqxGrid’s “updatebounddata” method.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comPeter Stoev Thank you very much!~ヾ(*´∀`*)ノ
-
AuthorPosts
You must be logged in to reply to this topic.