2016-12-12 2 views
0

Weiß jemand, warum Sortierung funktioniert nicht in eckigen ui-gird? Es sieht aus wie Einstellung Typ: 'String' und explizite enableSorting hat keine Auswirkungen.Angular Ui-Grid Sortierung funktioniert nicht

Ich benutze ui-gird v4.0, aber es funktioniert nicht mit früheren Version.

Optionen

//ui-grid options 
$scope.gridOptions = { 
    paginationPageSize: 30, 
    paginationPageSizes: [30, 60, 90], 
    useExternalSorting: true, 
    useExternalPagination: true, 
    rowHeight: 40, 
    showGridFooter: false, 
    enableSorting: true, 
    cellEditableCondition: true, 
    exporterMenuCsv: true, 
    exporterMenuPdf: false, 
    enableGridMenu: true, 
    columnDefs: [ 
    {field: 'actions', width: '100', enableFiltering: false, enableSorting: false, enableHiding: false, enableColumnMenu: false, cellTemplate: cellTemplate, headerCellTemplate: actionHeaderTemplate}, 
    {field: 'uploader', width: '150'}, 
    {field: 'files_name', width: '150', type: 'string', enableSorting: true}, 
    {field: 'sample_name', width: '120'}, 
    {field: 'ena_accession_nr', width: '150'}, 
    {field: 'pre_assembled', width: '130'}, 
    {field: 'sequencing_platform', width: '170'}, 
    {field: 'sequencing_type', width: '145'}, 
    {field: 'isolation_source', width: '140'}, 
    {field: 'source_notes', width: '120', enableSorting: false}, 
    {field: 'pathogenic', width: '105'}, 
    {field: 'pathogenicity_notes', width: '160', enableSorting: false}, 
    {field: 'organism', width: '95'}, 
    {field: 'strain', width: '75'}, 
    {field: 'subtype', width: '90'}, 
    {field: 'collection_date', width: '130'}, 
    {field: 'collected_by', width: '100'}, 
    {field: 'country', width: '120'}, 
    {field: 'region', width: '120'}, 
    {field: 'city', width: '100'}, 
    {field: 'zip_code', width: '100'}, 
    {field: 'latitude', width: '100'}, 
    {field: 'longitude', width: '100'}, 
    {field: 'location_notes', width: '30%', enableSorting: false}, 
    {field: 'notes', width: '30%', enableSorting: false}, 
    ], 
    onRegisterApi: function(gridApi) { 
    $scope.gridApi = gridApi; 
    $scope.gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) { 
     paginationOptions.pageNumber = newPage; 
     paginationOptions.pageSize = pageSize; 
     $scope.paginate(); 
    }); 
    } 
}; 

Paginator

// Function gets paginated data 
$scope.paginate = function() { 

    var successCallback = function(response) { 
    $scope.gridOptions.data = []; 
    $scope.gridOptions.totalItems = response.data.count; 

    // Normalize endpoint data -transform it to samples 
    for (var index in response.data.data) { 
     var samples = response.data.data[index][1]['metadata']; 
     var filesId = response.data.data[index][1]['files'].map(function(file){ return file.file_id; }); 

     samples['ids'] = filesId.join(); 
     samples['files_name'] = file.filename; 
     samples['sample_name'] = response.data.data[index][0]; 

     // add samples to grid data 
     $scope.gridOptions.data.push(samples); 
    } 
    } 

    var errorCallback = function(response) { 
    var message = (response.data['message'] != undefined) ? response.data.message : response.data.non_field_errors[0]; 
    alert.show('Error: ' + message, 'danger'); 
    } 

    var url = 'app/api/v1/user/samples?limit=' + paginationOptions.pageSize + '&page=' + paginationOptions.pageNumber; 
    $http.get(url).then(successCallback, errorCallback); 
} 

Daten

// Example of content of $scope.gridOptions.data[0] 
{ 
    city : "" 
    collected_by : "" 
    collection_date : "Unknown" 
    country : "Tanzania" 
    created_on : "2016-12-12T09:32:46.076532Z" 
    ena_accession_nr : "" 
    file_upload : "c9696fa4-421c-422c-9dac-039ceabab7f5" 
    files_name : "KLMC2.fna" 
    id : "c37e3963-6f68-443f-b076-aed7b975872d" 
    ids : "c9696fa4-421c-422c-9dac-039ceabad7a5" 
    isolation_source : "Other" 
    latitude : 0 
    location_notes : "" 
    longitude : 0 
    notes : "" 
    organism : "Unknown" 
    pathogenic : "Unknown" 
    pathogenicity_notes : "" 
    pre_assembled : "Yes" 
    region : "" 
    sample_name : "KLMC2" 
    sequencing_platform : "" 
    sequencing_type : "Unknown" 
    source_notes : "" 
    strain : "" 
    subtype : "" 
    uploader : "compare" 
    zip_code : "" 
} 
+0

Sind Sie ganz oder sein irgendeine spezifisches Szenario sortieren nicht in der Lage, wo Sie das Problem haben. –

+0

Ich kann nicht vollständig sortieren –

Antwort

1

Die Sortierung nicht aufgrund Gitter op arbeitete tion (useExternalSorting), die verhindert, dass die interne Sortierung ausgeführt wird.

Lösung: Set boolean false auf useExternalSorting Option.

useExternalSorting: false