Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column sorting not working properly #279

Closed
PaulChristopher opened this issue Sep 12, 2012 · 2 comments
Closed

Column sorting not working properly #279

PaulChristopher opened this issue Sep 12, 2012 · 2 comments

Comments

@PaulChristopher
Copy link

Run the attached test case. Click on one of the column headers so as to trigger sorting of the entries. It does not matter which column you sort: The last two entries are always sorted wrongly for some reason. Or am I missing something? I think I have done everything according to the docs and test cases...

Test case:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test dGrid</title>
<link rel="stylesheet" href="js/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="js/dgrid/css/dgrid.css">
<link rel="stylesheet" href="js/dgrid/css/skins/claro.css">
<style>
    .claro {
    font-family: Arial, Verdana, Helvetica, sans-serif;
    font-size: .75em;
    color: #000;
    }

    #Grid1 {
        width: 1000px;
        height: auto;
    }
    #Grid1 .dgrid-scroller {
        position: relative;
        overflow-y: hidden;
    }
    .has-ie-6 #Grid1 .dgrid-scroller {
        /* IE6 doesn't react properly to hidden on this page for some reason */
        overflow-y: visible;
    }
    #Grid1 .dgrid-header-scroll {
        display: none;
    }
    #Grid1 .dgrid-header {
        right: 0;
    }
</style>
<script>
    dojoConfig = { 
        staticStoreColumns: { gb: 'GB', step1: 'DUNS (1624)', step2: 'EBS (1902)', step3: 'SRM (3391)', erroneous: 'Erroneous (0)'},                    
        staticStoreData: [{ gb: 'CP/PIR-EW', step1:36, step2:0, step3:9, erroneous:0 },{ gb: 'C/REC', step1:12, step2:0, step3:0, erroneous:0 },{ gb: 'EB', step1:2, step2:0, step3:0, erroneous:0 },{ gb: 'CB', step1:6, step2:0, step3:0, erroneous:0 },{ gb: 'Blaupunkt', step1:0, step2:0, step3:0, erroneous:0 },{ gb: 'CP/PIR-SD', step1:4, step2:0, step3:1, erroneous:0 },{ gb: 'CP/PIR-MD', step1:2, step2:0, step3:1, erroneous:0 },{ gb: 'ST', step1:2, step2:0, step3:0, erroneous:0 },{ gb: 'CP/PIR-AP', step1:596, step2:325, step3:1200, erroneous:0 },{ gb: 'TT/PUI', step1:1, step2:0, step3:0, erroneous:0 },{ gb: 'CP/PIR-JP', step1:50, step2:0, step3:0, erroneous:0 },{ gb: 'UBK Purchasing', step1:25, step2:0, step3:2, erroneous:0 },{ gb: 'ST/PUI', step1:0, step2:0, step3:0, erroneous:0 },{ gb: 'DC', step1:4, step2:0, step3:1, erroneous:0 },{ gb: 'PT/PUI', step1:0, step2:0, step3:0, erroneous:0 },{ gb: 'PT', step1:80, step2:0, step3:0, erroneous:0 },{ gb: 'CP/PIR-LA', step1:3, step2:0, step3:10, erroneous:0 },{ gb: 'CP/PIR-ND', step1:231, step2:0, step3:2, erroneous:0 },{ gb: 'AA', step1:44, step2:0, step3:0, erroneous:0 },{ gb: 'C/CTI', step1:0, step2:0, step3:0, erroneous:0 },{ gb: 'CP/PIR-NA', step1:0, step2:0, step3:0, erroneous:0 },{ gb: 'CP/PIR-IN', step1:1, step2:1577, step3:1352, erroneous:0 },{ gb: 'Virtual Plant Suppliers', step1:211, step2:0, step3:813, erroneous:0 },{ gb: 'CP/PIR-EE', step1:245, step2:0, step3:0, erroneous:0 },{ gb: 'PA', step1:1, step2:0, step3:0, erroneous:0 },{ gb: 'TT', step1:68, step2:0, step3:0, erroneous:0 }]
    };
</script>
<script src="js/dojo/dojo.js" data-dojo-config="async:true, parseOnLoad:true, locale:'en'"></script>
<script>
     require([
         "dojo/ready",
         "dgrid/OnDemandGrid",
         "dojo/store/Memory",
     ],
     function (ready, Grid, Memory) {
         ready(function () {
             dojo.config.staticStoreData = new Memory({data:dojo.config.staticStoreData});
             this.Grid1 = new Grid({
                 store: dojo.config.staticStoreData,
                 columns: dojo.config.staticStoreColumns
             }, "Grid1");
         });
     });
</script>
</head>
<body class="claro">
    <h1>Test Sorting</h1>
    <div id="Grid1"></div>
</body>
</html>
@kfranqueiro
Copy link
Contributor

While I'm not entirely sure how to explain the exact behavior we're seeing as a result, I can explain the cause: you are instantiating dojo/store/Memory but have not assigned it an idProperty corresponding to a field which exists in your items. Therefore, idProperty is still defaulting to id, and presumably the index within the Memory store is all messed up. If I add idProperty: "gb" to the properties passed to new Memory, the sort works.

@PaulChristopher
Copy link
Author

Kenneth, thank you for your feedback. You are perfectly right: Just changing 'gb' to 'id' fixes the behaviour. So it is not a dgrid issue but a problem of a misconfigured store.

Keep up the good work! Cheers, Paul.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants