jQWidgets Forums

jQuery UI Widgets Forums Grid Unable to sort please help

This topic contains 1 reply, has 1 voice, and was last updated by  Blomotom 8 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Unable to sort please help #94697

    Blomotom
    Participant
    <!DOCTYPE html>
    <html lang="fr">
    <head>
        <title id='Description'></title>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> 
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"></script>	
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script>	
        <script type="text/javascript" src="../../jqwidgets/jqxgrid.storage.js"></script>	
        <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>	
        <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> 
        <script type="text/javascript" src="../../scripts/demos.js"></script>
        <script type="text/javascript">
         
       $(document).ready(function () {
               
    
            // prepare the data	
    	//var getLocalization = function () {
            //  var localizationobj = {};
            //  localizationobj.currencysymbol = " €";
    	//	 localizationobj.currencysymbolposition = "after";
            //   localizationobj.decimalseparator = ".";
            //    localizationobj.thousandsseparator = ",";
            //     return localizationobj;
            //  }
    			
    			
                var source =
                {
                    datatype: "json",
    		root: 'rows',
                    datafields: [
    			{ name: 'Number', type: 'float' },
                            { name: 'Name', type: 'string' },
    			{ name: 'Name2', type: 'string' },
    			{ name: 'Number2', type: 'float' },
    			{ name: 'Number3', type: 'float' }
                    ],
    		sortcolumn: 'Number3',
    		sortdirection: 'asc',
    		cache: false,
                    url: 'datan.php',
    		
    		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');
                    },
                    beforeprocessing: function(data) {
                        if (data != null && data.length > 0) {
                            source.totalrecords = data[0].totalRecords;
                        }
                    }
                };
                var filterChanged = false;
                var dataadapter = new $.jqx.dataAdapter(source, {
    				/*
    				// remove the comment to debug
                    formatData: function(data) {
    					alert(JSON.stringify(data));
                        return data;
                    },*/
                   downloadComplete: function(data, status, xhr) {
                       if (!source.totalRecords) {
                           source.totalRecords = data.length;
                      }
                  },
                 loadError: function(xhr, status, error) {
                       throw new Error(error);
                  }
               });
    
                $("#jqxgrid").jqxGrid(
                {
                    
    		autowidth: true,
    		autoheight: true,
                    source: dataAdapter,
    		autoheight: true,
    		sortable: true,
                    virtualmode: true,
                    rendergridrows: function(obj) {
                    return obj.data;
    					 },
                    columns: [
    
                     { text: 'Number', datafield: 'Number', width: 100},
    				 { text: 'Name', datafield: 'Name', width: 250},
    				 { text: 'Name2', datafield: 'Name2', width: 250} ,
    				 { text: 'Number2', datafield: 'Number2', width: 150},
    				 { text: 'Number3', datafield: 'Number3', width: 150}
    				// { text: 'Depense TTC', datafield: 'depense_ttc', width: 150, cellsformat: "c2", cellsalign: 'right'}
    
                  ]
                });
            });
        </script>
    	
    </head>
    <body class='default'>
        <div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;">
            <div id="jqxgrid"></div>
        </div>
    </body>
    </html>
    

    Hello.
    I have a problem to sort data from json.
    When i clic on “sort” on columns on index.php, LOADING… but don’t sort values or name.
    Could you help me please.
    Best regards.

    Unable to sort please help #94709

    Blomotom
    Participant

    solved, please delete this post

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

You must be logged in to reply to this topic.