jQWidgets Forums

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts

  • Shadok
    Participant

    Thanks Hristo.


    Shadok
    Participant

    Looks like it didn’t like my field named ‘id’.
    It works fine now.


    Shadok
    Participant

    And 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 …


    Shadok
    Participant

    Fixed it, I was missing 2 css :
    jqwidgets/styles/jqx.base.css
    jqwidgets/styles/jqx.black.css

Viewing 4 posts - 1 through 4 (of 4 total)