2014-09-17 3 views
2

검색 결과가 채워진 표가 있습니다. 정렬은 각 열의 모든 값이 숫자이거나 모두 동일한 경우 (위 또는 아래)에 있으면 올바르게 작동하는 것 같습니다. 그러나 firstname과 lastname과 같은 그리드의 일부 열은 대문자, 소문자 및 빈 값을 혼합 한 것입니다. 정렬 목적으로 특정 헤더를 클릭하면이 값은 대소 문자를 구분하여 정렬 된 것으로 보입니다. 대문자 값은 하나씩 나오고 빈 값과 소문자 값이 혼합되어 있습니다. 나는 알파벳순으로 대소 문자를 구분하지 않고이 정렬 작업을 수행하기를 원합니다. extjs는 ascii 값을 기반으로 이러한 값을 정렬한다고 생각합니다. 이 기능을 덮어 쓸 수있는 방법이 있습니까?Extjs- 격자 열 구분하지 않음 대/소문자 구분하지 않음

예를 들어 james, JAMESON 및 ROBERT와 같은 값이 있습니다. 오름차순의 경우 머리글 맨 위를 클릭하면 JAMESON, JAMESON 및 Robert와 위쪽/아래쪽에있는 모든 빈 값/null 값을 함께 가져야합니다. 그러나 그것은 일어나지 않습니다. 맨 위에 빈 값이오고 JAMESON, james, 빈 값이 다시 나타납니다. ROBERT 뒤에 빈 값/null 값이옵니다. 모든 null 값이 함께 그룹화되고 정렬이 대소 문자를 구분하지 않도록하는 방법은 무엇입니까?

{ 헤더 : "사용자 성", 폭 : 170, dataIndex : 'userLastName' }, { 헤더 : "사용자 이름", 폭 : 170, dataIndex : 'userFirstName' },

감사, 모델의 필드에

+0

모델의 외관은 어떻습니까? – JesseRules

답변

0
var itemsPerPage = 10; // set the number of items you want per page 

var data = { 

    "success" : true, 
    "users" : [{ 
      "id" : 1, 
      "name" : 'ed', 
      "email" : "[email protected]" 
     }, { 
      "id" : 2, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 3, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 4, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 5, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 44, 
      "name" : '1', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 45, 
      "name" : '2', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 11, 
      "name" : 'Ed', 
      "email" : "[email protected]" 
     }, { 
      "id" : 12, 
      "name" : 'apple', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 13, 
      "name" : 'Apple', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 14, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 15, 
      "name" : 'tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 21, 
      "name" : 'Ed', 
      "email" : "[email protected]" 
     }, { 
      "id" : 22, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 23, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 24, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 
     { 
      "id" : 25, 
      "name" : 'Tommy', 
      "email" : "[email protected]" 
     }, 

    ] 
} 
Ext.apply(Ext.data.SortTypes, { 
    asPerson : function (name) { 
     // expects an object with a first and last name property 
     console.log("Test"); 
     return name.toUpperCase() + name.toLowerCase(); 
    } 
}); 

var store = Ext.create('Ext.data.Store', { 

     autoLoad : true, 
     fields : [{ 
       name : 'name', 
       sortType : 'asPerson' 
      }, { 
       name : 'email' 
       // sortType set to asFloat 
      } 
     ], 
     pageSize : itemsPerPage, // items per page 


     data : data, 

     proxy : { 
      type : 'memory', 

      enablePaging : true, 
      reader : { 
       type : 'json', 
       root : 'users', 
       successProperty : 'success' 
      } 

     }, 

     sorters : [{ 
       property : 'name', 
       direction : 'ASC' 
      } 
     ], 

    }); 

//Ext.Ajax.request({ 
// loadMask: true, 
// url: 'app/data/users.json', 
// 
// success: function(resp) { 
//  // resp is the XmlHttpRequest object 
//  var options = resp.responseText; 
// 
// 
// 
//  store.loadData(options); 
// } 
//}); 
// 
// 


Ext.define('AM.view.user.list', { 
    extend : 'Ext.grid.Panel', 
    alias : 'widget.userlist', 

    title : 'All Users', 

    initComponent : function() { 

     Ext.create('Ext.grid.Panel', { 
      title : 'My Test Demo', 
      store : store, 
      columns : [{ 
        header : 'ID', 
        dataIndex : 'id' 
       }, { 
        header : 'Name', 
        dataIndex : 'name' 
       }, { 
        header : 'Email', 
        dataIndex : 'email', 
        flex : 1 
       } 
      ], 
      width : 350, 
      height : 280, 
      dockedItems : [{ 
        xtype : 'pagingtoolbar', 
        store : store, // same store GridPanel is using 
        dock : 'bottom', 
        displayInfo : true, 
        pageSize : 5, 

       } 
      ], 
      renderTo : Ext.getBody() 

     }); 

     this.callParent(arguments); 

    } 
}); 
+0

우리도 시도해 본다. –

0

ExtJS5에서는 변환자를 추가합니다. 예 :

sorters: { 
       transform: function(item) { 
        return item.toLowerCase(); 
       }, 
       property: 'category_name' 
      } 
관련 문제