Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Conditional select for ListGrid

    Hi,
    Currenly I'm trying to select particular rows and ignore other rows. I tried returning false in the selectionChanged method. This works fine by not selecting the row. But if I move my mouse cursor over the row it selects the row. Let me know if I'm missing something here. I've included a demo code below.

    [code]
    isc.ListGrid.create({
    ID: "countryList",
    width:500, height:224, alternateRecordStyles:true, showAllRecords:true,
    data: countryData,
    fields:[
    {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png"},
    {name:"countryName", title:"Country"},
    {name:"capital", title:"Capital"},
    {name:"continent", title:"Continent"}
    ],
    selectionType: "multiple",
    selectionChanged:function ()
    {
    if (countryList.getFocusRow () > 5)
    {
    alert (countryList.getFocusRow ());
    return false;
    }
    return this.Super ("selectionChanged", arguments);
    }
    })


    isc.ListGrid.create({
    ID: "selectedCountries",
    width:250, height:100, top:250, alternateRecordStyles:true, showAllRecords:true,
    emptyMessage: "<br>nothing selected</b>",
    fields:[
    {name:"countryName", title:"Selected countries"}
    ]
    })
    [\code]
    Last edited by Isomorphic; 19 Dec 2007, 12:04.

    #2
    Hi Mahen
    What's happening here is that the selectionChanged method is actually a notification function fired after the selection has changed, so by the time the method fires, the record has already been selected / deselected. Returning false from this method will not suppress the selection (I see that the documentation is slightly confusing for this method so we'll be sure to clear that up).

    Would simply disabling the records you want to be unselectable work for you?

    Comment


      #3
      Thanks for the reply. My requirement here is when I click on a row and start drag selecting all the rows, based on the first row column value I should allow or disallow other row selection. For instance if a row is selected initially and its country is US, during drag select, I should allow only rows having country as US and should not select other rows with different countries. Is it possible?

      Comment


        #4
        Hi Mahen,

        Your best approach is probably to allow logical selection to occur but avoid it being displayed. In outline:

        - when drag selection starts, remember the record that selection started on
        - override getBaseStyle so that, for records that should not become selected, you return a baseStyle where the selected style looks identical to the unselected style
        - when calling getSelection(), ignore records that you didn't actually want to be selected

        Comment

        Working...
        X