GridView - Disable the selection only for the end-user

4 posts, 1 answers
  1. Hu
    Hu avatar
    9 posts
    Member since:
    May 2020

    Posted 02 Jun Link to this post

    Hello,

    Please, may we disable the selection of a row only for the end-user?  It will need to be possible to manipulate the selection programmatically.

    Thanks

  2. Answer
    Nadya
    Admin
    Nadya avatar
    344 posts

    Posted 04 Jun Link to this post

    Hello Hu,

    RadGridView offers SelectionMode property that controls whether and how the cell in the grid can be selected. GridViewSelectionMode can be CellSelect, FullRowSelect or None. More information is available here. Following your requirement, you would like to disable selection only for the end-users but still be able to select programmatically.

    You can achieve this behavior by handling the SelectionChanging event which allows you to be canceled. Thus, you can raise a flag of boolean type and manage the selection in the grid as per your requirement. I created a sample project for your reference where selection is disabled when the raised flag is true and enabled when the flag is false ( for example when selecting a row programmatically on a button_Click event )

    I hope this helps. Let me know if you have other questions.

    Regards,
    Nadya
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
  3. Hu
    Hu avatar
    9 posts
    Member since:
    May 2020

    Posted 09 Jun in reply to Nadya Link to this post

    Dear Nadya,

    Thanks for your reply. 

    Your answer and sample project were very useful to solve the issue. 

    In fact, I was using Current rows properties (and not Selected as mentioned in the post). In any case, I use same approach as you described and was able to disable Current row for the end-user.

    Regards

  4. Nadya
    Admin
    Nadya avatar
    344 posts

    Posted 09 Jun Link to this post

    Hello Hu,

    I am glad that the suggested solution helps to resolve the problem that you had. If you need any further assistance do not hesitate to contact us.

    Regards,
    Nadya
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top