Conditional Formatting that dynamically responds to user interaction

Hello

I have a scenario where the user is presented with a grid like this:


When the user selects say Q11 (as above) then I want to disable (so they cannot tick the checkbox) all questions that are not of the same type. So in the above scenario questions of Type 01 and 03 would be disabled when the user ticked Q11. The main problem I am having is that it seems very difficult to get a handle on the records that I need to disable (so that I can add a class or style).  In previous versions of your controls there were many methods like MyGrid.GetRows(), but these have all been deprecated.  Any advise would be greatly appreciated.

Thanks

 







4 Replies

RS Renjith Singh Rajendran Syncfusion Team October 14, 2021 05:13 AM UTC

Hi Ditchford, 

Greetings from Syncfusion support. 

We suggest you to prevent the checkbox tick of corresponding rows using args.Cancel inside RowSelecting event of Grid. Please refer the codes below, 

 
<GridEvents RowSelecting="RowSelectHandler" TValue="Order"></GridEvents>
 
public async Task RowSelectHandler(RowSelectingEventArgs<Order> args) 
{ 
    List<Order> selectedRecords = await Grid.GetSelectedRecordsAsync(); 
    if (selectedRecords.Count() != 0) 
    { 
        if (selectedRecords.FirstOrDefault().Type != args.Data.Type) 
        { 
            //prevent the selection 
            args.Cancel = true; 
        } 
    } 
} 


 
Please get back to us if you need further assistance. 

Regards, 
Renjith R 



DI Ditchford October 14, 2021 07:53 AM UTC

Hey Renijith


Thanks for that. I think if I conditionally format the Types to different colors and prevent the click as you suggest then that will have to do. Its not quite what I was after because I wanted a visual clue about which records the user could click next (i.e. other records disabled). It does appear that since methods like  MyGrid.GetRows()  were deprecated then this will be very hard. Anyway I think I will say that "its not just good, its good enough" - Homer Simpson :-)

As a matter of interest were the methods such as MyGrid.GetRows() that were deprecated replaced with anything?


Thanks




DI Ditchford October 14, 2021 01:58 PM UTC

Hello Renijith

Fyi, I was able to get the other rows to respond (and appear disabled) using CSS:



I then set the opacity in the RowSelected/RowDeselected events to get the desired results.  This together with your code is the result I wanted.  I guess I could have done it all in CSS by setting pointer-events: none, but what I have works.

Thanks for your help



RS Renjith Singh Rajendran Syncfusion Team October 15, 2021 08:48 AM UTC

Hi Ditchford, 

Thanks for your update. From your update, We are glad to hear that you have achieved your requirement.  

Query : MyGrid.GetRows() that were deprecated replaced with anything?  
We would like to inform you that, it is not feasible to access and manipulate the DOM elements in Blazor. You can access and manipulate the DOM elements only during the Grid refresh as like what we have performed in RowDataBound events(below documentation). During refresh the RowDataBound event will be triggered and in that you can access the corresponding DOM element for that row and apply style. 

Please get back to us if you need further assistance. 

Regards, 
Renjith R 


Loader.
Up arrow icon