jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Jquery error : a is is undefined
This topic contains 3 replies, has 1 voice, and was last updated by Shadok 9 years, 5 months ago.
-
Author
-
Hello,
I’m using jQuery 2.1.4 with jqxwidgets up-to-date.
Usually, i’m using it without issue, but today, i’m stumbling upon this one.Error is “a is is undefined” and if i’m using the non-minified version I get :
TypeError: obj is undefined (line 348)
> length = obj.length,It’s related to this part of jQuery :
// args is for internal usage only each: function( obj, callback, args ) { var value, i = 0, length = obj.length,
Here’s my javascript :
$(function() { var data = [{"invoice_id":1541,"ref":"FA1512-1282","seller_name":"Vendeur","date":"2015-12-08","date_due":"2015-12-31","type":"Facture standard","total_net":14.51519,"total_commission":2.9,"status":"Impayée","company":"Société","commission_done":false}]; var source = { localdata: data, datafields: [ { name: 'invoice_id', type: 'int' }, { name: 'ref', type: 'string' }, { name: 'seller_name', type: 'string' }, { name: 'date', type: 'date' }, { name: 'date_due', type: 'date' }, { name: 'total_net', type: 'number' }, { name: 'total_commission', type: 'number' }, { name: 'status', type: 'string' }, { name: 'company', type: 'string' }, { name: 'commission_done', type: 'bool' }, ], datatype: "json", sortcolumn: 'invoice_id', sortdirection: 'desc', }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 700, source: dataAdapter, sortable: true, filterable: true, pageable: true, autoheight: true, autorowheight: true, editable: false, selectionmode: 'singlecell', pagesizeoptions: [10,25,50,100,250,500], columns: [ { text: 'ID', datafield: 'invoice_id', columntype: 'numberinput', cellsalign: 'left', cellsformat: 'n', hidden: true }, { text: 'Réf', datafield: 'ref', filtertype: 'textbox', width: 50, cellsalign: 'center' }, { text: 'Tiers', datafield: 'company', filtertype: 'textbox', width: 150 }, { text: 'Vendeur', datafield: 'seller_name', filtertype: 'textbox', width: 150 }, { text: 'Créé le', datafield: 'date', filtertype: 'date', width: 50, cellsalign: 'center' }, { text: 'Dû le', datafield: 'date_due', filtertype: 'date', width: 50, cellsalign: 'center' }, { text: 'Total HT', datafield: 'total_net', columntype: 'numberinput', filtertype: 'number', width: 80, cellsalign: 'center', cellsformat: "c3" }, { text: 'Comm.', datafield: 'total_commission', columntype: 'numberinput', filtertype: 'number', width: 80, cellsalign: 'center', cellsformat: "c3" }, { text: 'Statut', datafield: 'status', filtertype: 'textbox', width: 50, cellsalign: 'center' }, { text: '', datafield: 'commission_done', columntype: 'checkbox', filtertype: 'checkbox', width: 40, cellsalign: 'center' }, ] }); });
Any idea or hint please ?
Thanks.
Fixed it, I was missing 2 css :
jqwidgets/styles/jqx.base.css
jqwidgets/styles/jqx.black.cssAnd here it comes again, this time with css loaded (I don’t know why this was an issue earlier, but that’s not the case this time).
Mon json data, stored in lines variable :
[ { "id":"2628", "invoice_id":"1541", "type":"1", "total_net":"10.18811000", "total_vat":"2.04000000", "total":"12.23000000", "vat_rate":"20.000", "qty":"1", "text":"Consommations à destination de FRANCE Fixe : 12:07:36 (1467 appels/1467 au total)", "commission_amount":"20.00", "commission_type":"pourcentage", "commission_total":"2.04" }, { "id":"2629", "invoice_id":"1541", "type":"1", "total_net":"1.01008000", "total_vat":"0.20000000", "total":"1.21000000", "vat_rate":"20.000", "qty":"1", "text":"Consommations à destination de FRANCE Fixe (Numéros non géographiques) : 01:12:08 (135 appels/135 au total)", "commission_amount":"20.00", "commission_type":"pourcentage", "commission_total":"0.20" }, { "id":"2630", "invoice_id":"1541", "type":"1", "total_net":"3.31700000", "total_vat":"0.66000000", "total":"3.98000000", "vat_rate":"20.000", "qty":"1", "text":"Consommations à destination de FRANCE Mobile : 00:29:37 (37 appels/37 au total)", "commission_amount":"20.00", "commission_type":"pourcentage", "commission_total":"0.66" } ]
And my javascript :
var type = [ {value: '0', label: 'produit'}, {value: '1', label: 'service'}, ]; var typeSource = { datatype: "array", datafields: [ { name: 'label', type: 'string' }, { name: 'value', type: 'string' } ], localdata: type }; var typeAdapter = new $.jqx.dataAdapter( typeSource, { autoBind: true }); var commission_type = [ {value: 'montant', label: '€'}, {value: 'pourcentage', label: '%'}, ]; var commission_typeSource = { datatype: "array", datafields: [ { name: 'label', type: 'string' }, { name: 'value', type: 'string' } ], localdata: type }; var commission_typeAdapter = new $.jqx.dataAdapter( commission_typeSource, { autoBind: true }); var source = { localdata: lines, datafields: [ { name: 'id', type: 'int' }, { name: 'invoice_id', type: 'int' }, { name: 'Type', value: 'type', values: { source: typeAdapter.records, value: 'value', name: 'label' } }, { name: 'total_net', type: 'number' }, { name: 'total_vat', type: 'number' }, { name: 'total', type: 'number' }, { name: 'vat_rate', type: 'number' }, { name: 'qty', type: 'number' }, { name: 'text', type: 'string' }, { name: 'commission_amount', type: 'number' }, { name: 'Commission_type', value: 'commission_type', values: { source: commission_typeAdapter.records, value: 'value', name: 'label' } }, { name: 'commission_total', type: 'number' }, ], datatype: "json", sortcolumn: 'id', sortdirection: 'asc', updaterow: function( rowid, rowdata, commit ) { $.ajax({ type: 'POST', dataType: 'json', url: '/commission/hasgard/includes/invoiceUpdate.php', data: {id: id, commission_amount: rowdata.commission_amount, commission_type: rowdata.commission_type}, success: function( data, status, xhr ) { commit( true ); }, error: function () { commit( false ); addError( 'Impossible de mettre les informations à jour : ' + jqXHR.responseText ); } }); } }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 1020, source: dataAdapter, sortable: true, filterable: true, pageable: true, autoheight: true, autorowheight: true, editable: false, selectionmode: 'singlerow', pagesizeoptions: [10,25,50,100,250,500], columns: [ { text: 'ID', datafield: 'id', columntype: 'numberinput', cellsalign: 'left', cellsformat: 'n', hidden: true }, { text: 'Description', datafield: 'text', filtertype: 'textbox', width: 200 }, { text: 'Type', datafield: 'type', displayfield: 'Type', columntype: 'dropdownlist', width: 40, editable: true, cellsalign: 'center' }, { text: 'Total HT', datafield: 'total_net', columntype: 'numberinput', filtertype: 'number', width: 120, cellsalign: 'center', cellsformat: "c3" }, { text: 'TVA', datafield: 'total_vat', columntype: 'numberinput', filtertype: 'number', width: 100, cellsalign: 'center', cellsformat: "c3" }, { text: 'Total TTC', datafield: 'total', columntype: 'numberinput', filtertype: 'number', width: 120, cellsalign: 'center', cellsformat: "c3" }, { text: 'Commission', datafield: 'commission_amount', columntype: 'numberinput', filtertype: 'textbox', width: 120, cellsalign: 'center', cellsformat: "f5", validation: function (cell, value) { if( value < 0 ) { return { result: false, message: "La valeur saisie doit être positive ou nulle" }; } return true; }, initeditor: function (row, cellvalue, editor) { editor.jqxNumberInput({ decimalDigits: 2, digits: 5 }); } }, { text: '', datafield: 'commission_type', displayfield: 'Commission_type', columntype: 'dropdownlist', width: 40, editable: true, cellsalign: 'center', createeditor: function (row, value, editor) { editor.jqxDropDownList( {source: typeAdapter, placeHolder: "Type :", displayMember: 'label', valueMember: 'value' } ); }, cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { if (newvalue == "") return oldvalue; } }, { text: 'Total Comm.', datafield: 'commission_total', columntype: 'numberinput', filtertype: 'number', width: 120, cellsalign: 'center', cellsformat: "c3" }, ] }); var localizationobj = { currencysymbol: " €", currencysymbolposition: "after", decimalseparator: '.', thousandsseparator: '', pagergotopagestring: "Page :", pagershowrowsstring: "Lignes :", pagerrangestring: " de ", pagerpreviousbuttonstring: "précédent", pagernextbuttonstring: "suivant", sortascendingstring: "Tri croissant", sortdescendingstring: "Tri décroissant", sortremovestring: "Ne plus trier", filterclearstring: "Effacer", filterstring: "Filtrer", filtershowrowstring: "Montrer les lignes où :", filterorconditionstring: "OU", filterandconditionstring: "ET", filterselectallstring: "(Tous)", filterchoosestring: "Choisissez :", filterstringcomparisonoperators: ['vide', 'non vide', 'contient', 'contient (casse)', 'ne contient pas', 'ne contient pas (casse)', 'commence par', 'commence par (casse)', 'termine par', 'termine par (casse)', 'égal', 'égal (casse)', 'nul', 'non nul'], filternumericcomparisonoperators: ['égal', 'non égal', 'inférieur à', 'inférieur ou égal à', 'supérieur', 'supérieur ou égal à', 'vide', 'non vide'], filterdatecomparisonoperators: ['equal', 'not equal', 'less than', 'less than or equal', 'greater than', 'greater than or equal', 'null', 'not null'], filterbooleancomparisonoperators: ['equal', 'not equal'], validationstring: "Saisie invalide", emptydatastring: "Pas de données à afficher", filterselectstring: "Sélectionner le filtre", loadtext: "Chargement ...", clearstring: "Effacer", todaystring: "Aujourd'hui", }; $("#jqxgrid").jqxGrid( 'localizestrings', localizationobj ); $("#jqxgrid").on("sort", function (event) { var sortinformation = event.args.sortinformation; var sortdirection = sortinformation.sortdirection.ascending ? "ascending" : "descending"; if( !sortinformation.sortdirection.ascending && sortinformation.sortdirection.descending ) { sortdirection = "null"; } });
I’m feeling cursed by this error …
Looks like it didn’t like my field named ‘id’.
It works fine now. -
AuthorPosts
You must be logged in to reply to this topic.