C1FlexGrid - multiselect with checkbox

Posted by: abacrotto on 25 October 2018, 11:26 pm EST

    • Post Options:
    • Link

    Posted 25 October 2018, 11:26 pm EST

    I have developed a custom C1FlexGrid containing a lot of rows with n - 1 columns that are read only and have contextual data and only one column, with a checkbox, allowing the program operator to select some rows in the grid. I have added the possibility to multiselect. The problema I am facing is the number of events I get when the operator checks a lot of the files in a multiselect. I am using the AfterEdit event that gets raised once for each of the selected rows that get chaecked/unchecked. I would like to have only one event indicating that a change has happened. Is there a way for me to do it with C1FlexGrid?

    Thanks in advance.

    Regards.

    Ariel.

  • Posted 28 October 2018, 11:13 pm EST

    Hi Ariel,

    If the checkboxes are changed individually then the AfterEdit event would be fired multiple times and there’s no mechanism to suppress it. What you can do is add a checkBox on the ColumnHeader and use that to check/uncheck all the cells. This way the AfterEdit event is triggered only once,i.e. for the ColumnHeader cell. Please refer to the attached sample for an example.

    Regards,MultipleCheckBox.zip

  • Posted 29 October 2018, 12:05 am EST

    There is NO other way to implement exactly what I want? We don´t want to select all or deselect all. We need to select a range of rows and check those; and we need that operation to raise only one event. Is that no possible at all?

    Thanks in advance.

    Ariel.

  • Posted 29 October 2018, 5:21 pm EST

    Hi Ariel

    There appears to be some confusion as it seemed from your previous thread that the checkboxes were to be used for the selection process.

    Just to confirm, you want the users to select some rows first and then edit the checkBox state(for example using the SpaceBar key)? In that case, you can override the “OnAfterEdit” event and supress it for the the entire range of rows other than the first row of the selected range as shown below:

    
    protected override void OnAfterEdit(RowColEventArgs e)
            {
                //"AfterEdit" event fires in a BottomUp approach for the selected range
                if (e.Row != this.Selection.r1)
                    return;
                base.OnAfterEdit(e);
            }
    
    

    For reference please see the attached sample.

    Regards

    MultiCheckBox.zip

  • Posted 30 October 2018, 1:15 am EST

    Abhi:

    Thanks in advance for the trick. I have some minor anoyances, anyway. a) When selecting, deselecting only one row, the event seems not to fire; b) When there is a selection checked and I try to unckeck that same selection by clicking one of the checkboxes, the event seems not to fire. We are using the event (AfterEdit in a cell) for making calculations on decimal values in the rest of the fields in the grid’s datasource (filtering only the checked rows), so it’s very important the in both (a) and (b) the event gets raised. Can you help me with that problem, please?

    Thanks in advance.

    Ariel.

  • Posted 30 October 2018, 4:05 pm EST

    Hi Ariel

    Can you please share the build version of C1FlexGrid you are using?, We have checked it with the latest build version of C1FlexGrid(4.0.20182.320) and the event is getting fired in both the scenarios that you’ve mentioned.

    Regards

  • Posted 31 October 2018, 12:29 am EST

    Ooops. We do have 2.6.20113.652 now. Can that be the a problem with the implementation I am trying to do? If so, what are the paths for us to upgrade to your version? Can we test your assembly for being sure it works for me?

    Thanks in advance.

    Regards.

    Ariel.

  • Posted 31 October 2018, 8:36 pm EST

    Hi Ariel

    Thanks for sharing the build version. We checked with builds near that release and had the same observations as earlier. On further debugging, we found that for your scenario (b) there are some boundary cases for which the event was not getting triggered with the solution we had provided earlier. Apologies for the confusion.

    We’ve modified the solution that makes some more checks related to the checked/uncheked rows in the selection and thereafter allows the AfterEdit event to fire. Please refer to the attached sample for the details.

    Regards

    MultiCheckBox.zip

  • Posted 23 November 2018, 1:25 am EST

    Dear Abhishek:

    Finally, that last code you sent me did all what we needed the grid to do for us.

    I can not thank you enough for your help.

    We can close the ticket whenever you want.

    Regards.

    Ariel.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels