0

I m not able to keep the selectionMode as "single" or "extended". Only multiple selection of rows is happening, when I m using a dojo Memory/ ObjectStore as store.

    require([
    "dojo/_base/declare",
    "dojo/request",
    "dojo/data/ObjectStore",
    "dojo/store/Memory",
    "dgrid/OnDemandGrid",
    "dgrid/Keyboard",
    "dgrid/Selection",
    "dojo/DeferredList",
    "dojo/domReady!"
    ],
    function (declare, request, ObjectStore, Memory, OnDemandGrid, Keyboard, Selection, DeferredList) {

        var ddstore;


        claimDef = dojo.xhrGet({
            url: "pageToGetData.aspx",
            handleAs: "json",
            load: function (res) {
                // Resolve when content is received 
                ddstore = new Memory({ data: res });

            }
        });


        var defs = new dojo.DeferredList([claimDef]);
        defs.then(function (results) {
            // Create a new constructor by mixing in the components
            var CustomGrid = declare([OnDemandGrid, Keyboard, Selection]);

            claimAccountsGrid = new CustomGrid({
                columns: [
                { label: "Label1", field: "Field1" },
                { label: "Label2", field: "Field2" },
                { label: "Label3", field: "Field3" },
             ]

            }, "claimAccountsGrid");
            claimAccountsGrid.setStore(ddstore);


        });
    });

But, when I m hard-coding the same data that is obtained from that page, I m able to get the default selectionMode as "extended".(This way):

    require([
    "dojo/_base/declare",
    "dojo/request",
    "dojo/data/ObjectStore",
    "dojo/store/Memory",
    "dgrid/OnDemandGrid",
    "dgrid/Keyboard",
    "dgrid/Selection",
    "dojo/DeferredList",
    "dojo/domReady!"
    ],
    function (declare, request, ObjectStore, Memory, OnDemandGrid, Keyboard, Selection, DeferredList) {
        pageNo = 1;
        var ddstore;


        claimDef = dojo.xhrGet({
            url: "pageToGetData.aspx",
            handleAs: "json",
            load: function (res) {
                // Resolve when content is received 
                ddstore = //new Memory({ data: res });

                [
                { "Field1": "value1", "Field2": null, "Field3": "1" },
                { "Field1": "value2", "Field2": null, "Field3": "1"}
                ];
            }
        });


        var defs = new dojo.DeferredList([claimDef]);
        defs.then(function (results) {
            // Create a new constructor by mixing in the components
            var CustomGrid = declare([OnDemandGrid, Keyboard, Selection]);

            claimAccountsGrid = new CustomGrid({
                columns: [
                { label: "Label1", field: "Field1" },
                { label: "Label2", field: "Field2" },
                { label: "Label3", field: "Field3" },
             ]
            }, "claimAccountsGrid");
            //claimAccountsGrid.setStore(ddstore);
            claimAccountsGrid.renderArray(ddstore);

        });
    }); 
Sandy
  • 466
  • 6
  • 15
  • Try this `ddstore = new Observable(new Memory({ data: res }));` for this you need to require it as `dojo/store/Observable`. I hope it work for you Good Luck!. – Mithlesh Kumar Aug 09 '13 at 19:40
  • Thanks for the reply. But, using dojo/store/Observable didn't work as well. – Sandy Aug 09 '13 at 20:05
  • Inside dgrid folder there is test folder checkout this folder may be you get any example to find any helpful solution. – Mithlesh Kumar Aug 09 '13 at 20:18

1 Answers1

2

Since you haven't shown the actual data I can't be 100% certain, but this is something that happens if you fail to properly ensure your items have unique identifiers (or, if the identifier field is something other than id, you forgot to set idProperty on the Memory store to inform it of what field to look at).

See also https://github.com/SitePen/dgrid/issues/61

Ken Franqueiro
  • 10,559
  • 2
  • 23
  • 40