2012-12-31 1 views
3

Je suis en train de changer l'ordre de tri des jqGrid en utilisant ce code:icône Tri pas mise à jour sur la configuration du sortorder

jQuery('#id').setGridParam({sortorder:"desc"}).trigger("reloadGrid"); 

Il change la sortorder de la table mais le tri Icône de la table ne change pas selon la commande. Dans onSortCol je trier la colonne qui trient réellement la colonne. Mais quand j'utilise le morceau de code ci-dessus pour régler le tri, le tri est réglé mais l'icône de tri montre toujours le tri précédent.

_table.jqGrid({ 

     datatype: 'local', // disable initial autoload. this will be when load function is called "json", 
     altRows: true, 
     altclass : 'AltRowClass', 
     gridView: true, 
     width:850, 
     height:"auto", 
     rowheight: 75,   
     align: 'center', 
     treeGrid: false, 
     loadonce:true, 
     ExpandColumn: 'name', 
     loadtext : 'Currently updating', 
     mtype : 'POST', 
     colNames: ['MSISDN','IMSI','Last name','First name','Device type','CE Index','Customer lifetime value'], 
     colModel: [ 
        { name: 'MSISDN', align: 'center', hidden: false, sortable: false,formatter: maskingColumn}, 
        { name: 'IMSI', align: 'center', hidden: false, sortable: false,formatter: maskingColumn}, 
        { name: 'LastName', align: 'center', hidden: false, sortable: false}, 
        { name: 'FirstName', align: 'center', hidden: false, sortable: false}, 
        { name: 'DeviceType', align: 'center', hidden: false, sortable: false,formatter: columnData}, 
        { name: 'CEIndex', align: 'center', hidden: false, sortable: true, sorttype: 'int'}, 
        { name: 'CustomerLifetimeValue', align: 'center', hidden: false, sortable: false} 
        ], 
     sortname: 'CEIndex', 
     sortorder: 'desc', 
     loadComplete: function(data) 
     { 
      var rowCount = _table.jqGrid('getGridParam', 'records'); 

      if (rowCount > 5) { 
       _table.parents("div.ui-jqgrid-bdiv").css({'max-height':'300px'}); 
       _table.closest(".ui-jqgrid-bdiv").css({'overflow-y':'auto'}).css({'overflow-x':'hidden'}); 
      } 
      if (rowCount != 0) { 
       _table.parents().find('.ui-jqgrid-view').first().show(); 
      } 
      if (rowCount <= rowsNum) { 
       utils.find('cei-drill-customer-detail-showmore').hide(); 
      } else { 
       utils.find('cei-drill-customer-detail-showmore').show(); 
      } 
      _table.trigger("reloadGrid"); 
     } , 
     onSortCol: function (data, status, xhr) { 
      if (xhr == 'asc') { 
       var postData = this.p.postData.jsonRequest.replace('Top','Bottom'); 
       actionInputObjectExportCustDrilldown.parameters.requestQuery = actionInputObjectExportCustDrilldown.parameters.requestQuery.replace('Top','Bottom'); 
       var postDataVar = { 
         operation : 'drillDownLevel1', 
         drillLevel1 : "drilldown", 
         jsonRequest : postData 
       }; 
       _this.load(postDataVar); 
      } else if (xhr == 'desc') { 
       var postData = this.p.postData.jsonRequest.replace('Bottom','Top'); 
       actionInputObjectExportCustDrilldown.parameters.requestQuery = actionInputObjectExportCustDrilldown.parameters.requestQuery.replace('Bottom','Top'); 
       var postDataVar = { 
         operation : 'drillDownLevel1', 
         drillLevel1 : "drilldown", 
         jsonRequest : postData 
       }; 
       _this.load(postDataVar); 
      } 
     }, 
     beforeProcessing : function(data, status, xhr) { 
      jQuery('div#jqgh_' + prefix + '-cei-dd-customer-details-table_CustomerLifetimeValue.ui-jqgrid-sortable').text("Customer Lifetime Value(" + filterValuesHl.currency + ")"); 
      if (data.queryError != null || !data.rows || data.rows.length == 0) { 
       utils.find('cei-drill-customer-detail-ExportShowMore').hide(); 
       utils.find('div-for-export-customer').hide(); 
       var noError = utils.find('cei-customerDetails-div').parent().find(".cei-customer-details-dd-no-data"); 
       if (data.queryError != null) { 
        noError.text("Error in portlet: " + data.queryError); 
       } else { 
        noError.html("<strong>No Data Available</strong>"); 
       } 
       noError.show(); 
       return false; 
      } else { 
       utils.find('cei-drill-customer-detail-ExportShowMore').show(); 
       utils.find('div-for-export-customer').show(); 
       utils.find('cei-drill-customer-detail-showmore').show(); 
       //Hiding the columns which has no data in all the rows. 
       hideColumns(data); 
       //Setting CSV Data 
       csvData = data; 
      } 
     }, 
     beforeRequest : function() { 
      _table.parents().find('.ui-jqgrid-view').first().hide(); 
      utils.find('cei-customerDetails-div').parent().find(".cei-customer-details-dd-no-data").hide(); 
     }, 
     loadError : function(xhr, st, err) { 
      utils.find('cei-drill-customer-detail-ExportShowMore').hide(); 
      utils.find('div-for-export-customer').hide(); 
      var noError = utils.find('cei-customerDetails-div').parent().find(".cei-customer-details-dd-no-data"); 
      noError.html("<html>Error connecting portlet: " + err + "</strong>"); 
      noError.show(); 
     } 

    }); 

Répondre

0

Vous pouvez essayer le code suivant où id est votre nom de colonne.

$('#grid').jqGrid('setGridParam', {sortorder: 'desc'}); $('#grid').jqGrid('sortGrid', 'id');

Questions connexes