jQWidgets Forums
Forum Replies Created
-
Author
-
Dear Nadezda,
This is the entire code.
myWindow is a simply new window, that is not part of the jqxWidgets. Despite of this i have a problem with the addDialog, which i have already described.
I can’t believe that it solved my problem.
Thank you!
Thank you for the support Dimitar.
It was the server side, i have sent wrong variable.I go this in the console: ReferenceError: Can’t find variable: Globalize
The error thrown is: Syntax error: JSON parse error, unexpected identifier.It’s strange because i don’t expect any JSON.
I moved the dunction outside the dataTable like thisfunction saveInvoice(rowData) { var data = "insert=true&" + $.param(rowData); $.ajax({ dataType: 'json', url: 'json_documents.php', cache: false, data: data, success: function (data, status, xhr) { // update command is executed. //commit(true); }, error: function (jqXHR, textStatus, errorThrown) { //commit(false); alert(errorThrown); } }); }
Because i want simply send data w/out updating the #dataTable.
January 24, 2015 at 7:03 pm in reply to: DataTable check in JSON returns null DataTable check in JSON returns null #65960I have no error.Just when returns null, the table stacks on “loading”
January 23, 2015 at 1:39 pm in reply to: What is the right approach? What is the right approach? #65928Now it works!
January 22, 2015 at 8:32 am in reply to: What is the right approach? What is the right approach? #65827Now everything is OK.But i’m still looking for an answer of the question is this the right way to achieve this.I mean moderating the url and send it with GET?Because i also want the user to select whether some of the columns to be included or not, display only some users sales etc.
January 21, 2015 at 2:48 pm in reply to: What is the right approach? What is the right approach? #65782I have changed the code like this, unfortunately it doesn’t load nothing! In same time when manually trigger the url the PHP return right JSON:
$("#startDate").jqxDateTimeInput({width: '200px', height: '25px', formatString: "yyyy-MM-dd"}); $("#endDate").jqxDateTimeInput({width: '200px', height: '25px', formatString: "yyyy-MM-dd"}); $("#submitButton").jqxButton({width: '100px', height: '25px'}); $("#submitButton").mousedown(function() { var start = $('#startDate').val(); var end = $('#endDate').val(); var url = 'json_sales.php?' + "startDate=" + start + "&endDate=" + end; var source = { datatype: "json", datafields: [ { name: 'GoodID', type: 'string'}, { name: 'ObjectID', type: 'string'}, { name: 'Qtty' , type: 'double'}, { name: 'PriceOut' , type: 'double'}, { name: 'UserID' , type: 'string'}, { name: 'Total' , type: 'double'} ], url: url, cache: false, addRow: function (rowID, rowData, position, commit) { // synchronize with the server - send insert command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failed. // you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB. commit(true); }, updateRow: function (rowID, rowData, commit) { var data = "update=true&" + $.param(rowData); $.ajax({ dataType: 'json', url: 'json_products.php', cache: false, data: data, success: function (data, status, xhr) { // update command is executed. commit(true); }, error: function (jqXHR, textStatus, errorThrown) { commit(false); alert('Does not work :('); } }); }, deleteRow: function (rowID, commit) { // synchronize with the server - send delete command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failed. commit(true); } }; var dataAdapter = new $.jqx.dataAdapter(source); $("#dataTable").jqxDataTable( { width: 850, pageable: false, pagerButtonsCount: 10, source: dataAdapter, filterable: true, filtermode: 'simple', sortable: true, columnsResize: false, altRows: true, showAggregates: true, aggregatesHeight: 60, columns: [ //{ text: 'Acct', dataField: 'Acct', width: 100 }, { text: 'Описание:', dataField: 'GoodID', width: 350 }, //{ text: 'PartnerID', dataField: 'PartnerID', width: 350 }, { text: 'Обект:', dataField: 'ObjectID', cellsFormat: 'f', width: 100 }, { text: 'Потребител:', dataField: 'UserID', width:100}, { text: 'К-во:', dataField: 'Qtty' , width: 100}, { text: 'Цена:', dataField: 'PriceOut', width:100}, { text: 'Общо:', dataField: 'Total', width:100, aggregates: [{ 'Total': function (aggregatedValue, currentValue, column, record) { var total = currentValue * parseInt(record['Qtty']); return aggregatedValue + total; } }], aggregatesRenderer: function (aggregates, column, element) { var renderString = "<div style='margin: 4px; float: right; height: 100%;'>"; renderString += "<strong>Всичко: </strong>" + aggregates.Total + "<br><strong>С ДДС:</strong>" + (aggregates.Total*1.2) + "</div>"; return renderString; } } ] }); //dataAdapter.dataBind(); //$("#dataTable").jqxDataTable('updateBoundData'); window.alert(url); }); $("#excelExport").jqxButton(); $("#xmlExport").jqxButton(); $("#csvExport").jqxButton(); $("#tsvExport").jqxButton(); $("#htmlExport").jqxButton(); $("#jsonExport").jqxButton(); $("#excelExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'xls'); }); $("#xmlExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'xml'); }); $("#csvExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'csv'); }); $("#tsvExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'tsv'); }); $("#htmlExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'html'); }); $("#jsonExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'json'); }); $("#printButton").jqxButton({ width: 80 }); $("#printButton").click(function () { var gridContent = $("#dataTable").jqxDataTable('exportData', 'html'); var newWindow = window.open('', '', 'width=800, height=500'), document = newWindow.document.open(), pageContent = '<!DOCTYPE html>' + '<html>' + '<head>' + '<meta charset="utf-8" />' + '<title>jQWidgets DataTable</title>' + '</head>' + '<body>' + gridContent + '</body></html>'; document.write(pageContent); document.close(); newWindow.print(); }); });
January 20, 2015 at 9:17 am in reply to: What is the right approach? What is the right approach? #65668var url = 'json_sales.php'; var source = { datatype: "json", datafields: [ { name: 'GoodID', type: 'string'}, { name: 'ObjectID', type: 'string'}, { name: 'Qtty' , type: 'double'}, { name: 'PriceOut' , type: 'double'}, { name: 'UserID' , type: 'string'}, { name: 'Total' , type: 'double'} ], url: url, cache: false, addRow: function (rowID, rowData, position, commit) { // synchronize with the server - send insert command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failed. // you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB. commit(true); }, updateRow: function (rowID, rowData, commit) { var data = "update=true&" + $.param(rowData); $.ajax({ dataType: 'json', url: 'json_products.php', cache: false, data: data, success: function (data, status, xhr) { // update command is executed. commit(true); }, error: function (jqXHR, textStatus, errorThrown) { commit(false); alert('Does not work :('); } }); }, deleteRow: function (rowID, commit) { // synchronize with the server - send delete command // call commit with parameter true if the synchronization with the server is successful // and with parameter false if the synchronization failed. commit(true); } }; var dataAdapter = new $.jqx.dataAdapter(source); $("#dataTable").jqxDataTable( { width: 850, pageable: false, pagerButtonsCount: 10, source: dataAdapter, filterable: true, filtermode: 'simple', sortable: true, columnsResize: false, altRows: true, showAggregates: true, aggregatesHeight: 60, columns: [ //{ text: 'Acct', dataField: 'Acct', width: 100 }, { text: 'Описание:', dataField: 'GoodID', width: 350 }, //{ text: 'PartnerID', dataField: 'PartnerID', width: 350 }, { text: 'Обект:', dataField: 'ObjectID', cellsFormat: 'f', width: 100 }, { text: 'Потребител:', dataField: 'UserID', width:100}, { text: 'К-во:', dataField: 'Qtty' , width: 100}, { text: 'Цена:', dataField: 'PriceOut', width:100}, { text: 'Общо:', dataField: 'Total', width:100, aggregates: [{ 'Total': function (aggregatedValue, currentValue, column, record) { var total = currentValue * parseInt(record['Qtty']); return aggregatedValue + total; } }], aggregatesRenderer: function (aggregates, column, element) { var renderString = "<div style='margin: 4px; float: right; height: 100%;'>"; renderString += "<strong>Всичко: </strong>" + aggregates.Total + "<br><strong>С ДДС:</strong>" + (aggregates.Total*1.2) + "</div>"; return renderString; } } ] }); $("#startDate").jqxDateTimeInput({width: '200px', height: '25px', formatString: "yyyy-MM-dd"}); $("#endDate").jqxDateTimeInput({width: '200px', height: '25px', formatString: "yyyy-MM-dd"}); $("#submitButton").jqxButton({width: '100px', height: '25px'}); $("#submitButton").mousedown(function() { var start = $('#startDate').val(); var end = $('#endDate').val(); source.url = 'json_sales.php?' + "startDate=" + start + "&endDate=" + end; dataAdapter.dataBind(); $("#dataTable").jqxDataTable('updateBoundData'); window.alert(source.url); }); $("#excelExport").jqxButton(); $("#xmlExport").jqxButton(); $("#csvExport").jqxButton(); $("#tsvExport").jqxButton(); $("#htmlExport").jqxButton(); $("#jsonExport").jqxButton(); $("#excelExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'xls'); }); $("#xmlExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'xml'); }); $("#csvExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'csv'); }); $("#tsvExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'tsv'); }); $("#htmlExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'html'); }); $("#jsonExport").click(function () { $("#dataTable").jqxDataTable('exportData', 'json'); }); $("#printButton").jqxButton({ width: 80 }); $("#printButton").click(function () { var gridContent = $("#dataTable").jqxDataTable('exportData', 'html'); var newWindow = window.open('', '', 'width=800, height=500'), document = newWindow.document.open(), pageContent = '<!DOCTYPE html>' + '<html>' + '<head>' + '<meta charset="utf-8" />' + '<title>jQWidgets DataTable</title>' + '</head>' + '<body>' + gridContent + '</body></html>'; document.write(pageContent); document.close(); newWindow.print(); });
January 19, 2015 at 5:28 pm in reply to: What is the right approach? What is the right approach? #65627Thank you for your answer.
I changed it with your code.Unfortunately nothing happens.No data loads in the table.The url is correct, because i tested it and it returns correct JSON objects.Meaninng like this:
$("#addDialog").jqxWindow({ resizable: false, isModal: true, position: { left: $("#dataTable").offset().left + 300, top: $("#dataTable").offset().top + 35 }, width: 400, height: 270, autoOpen: false $("#addDialog").jqxValidator({ rules: [ { input: "#_userPassword", message: "Password is required!", action: 'keyup, blur', rule: 'required' }, { input: "#_userPasswordConfirm", message: "Password is required!", action: 'keyup, blur', rule: 'required' }, { input: "#_userPasswordConfirm", message: "Passwords should match!", action: 'keyup, blur', rule: function (input, commit) { var firstPassword = $("#_userPassword").jqxPasswordInput('val'); var secondPassword = $("#_userPasswordConfirm").jqxPasswordInput('val'); return firstPassword == secondPassword; } } ], hintType: "label" }); });
i got an error:
SyntaxError: Unexpected identifier ‘$’. Expected ‘}’ to end a object literal.
Thanks Peter!
I tought there is a shorter way to update all items from the source istead to bind each of them.
It works.Dear Peter,
updateRow requires new values! What i need is simply update the cell(if needed row) from the source
Problem solved.I was with the previous version of jqwidgets!
After updating and clear the cache , now works!Dear Petar,
Sorry for the name.I didn’t make it on purpose.
It’s pitty you can’t reproduce the problem, because without this expected behaviour the system i have planned to create will be impossible. -
AuthorPosts