How to display column in grid when I click on grid

I have an syncfusion grid control  with 15 columns.I would like to show  first five column in grid on initial load.When I click on grid row then I would like to display remaining 10 columns as in accordion format.


13 Replies

JP Jeevakanth Palaniappan Syncfusion Team July 13, 2021 08:11 AM UTC

Hi Hassan, 

Greetings from Syncfusion support. 

We have checked your query and we suspect that you are asking requirement similar to the hierarchy grid/ details template. Please refer the below online demo and documentation link for your reference. 


Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 



KI KINS July 13, 2021 10:24 AM UTC

please check my comments in attached file


Attachment: Transaction_04__Copy_c53580fd.zip


KI KINS July 13, 2021 01:41 PM UTC

Please help



KI KINS July 14, 2021 04:56 AM UTC



JP Jeevakanth Palaniappan Syncfusion Team July 14, 2021 12:25 PM UTC

Hi Hassan, 

Query 1: How to display columns when clicking on a row 

Based on your scenario, we suggest you to use the detail template feature of the grid. With this you can customize the detail row based on your requirement. Please refer the below screenshot, documentation and the sample for your reference. 

 


Query 2: Responsive grid 
 
We suspect that you want to show the columns responsively. Please refer the below documentation for HideAtMedia feature in grid to achieve your scenario. 
 

Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 



KI KINS July 14, 2021 01:20 PM UTC

Thanks for quick support...

I need to show remaining column in accordion type or popup when I click on grid row.


Please check attached file and below example which is my exact requirement.


For example :-

I have below 14 columns in Data source

1.SRFNo

2.Product

3.Buyer

4.Gender

5.StyleNo

6.Season

7.RefNo

8.SizeClass

9.Collection

10.RequestedBy

11.Descriptions

12.WidthClass

13.Last 

14.LastNo


I need to show serial No 1 to 9 in main grid 

and serial 10 to 14 should be display in accordion or popup windows when I click on grid row.


Hope its clear......





Attachment: accordion_popup_7cdecdba.zip


JP Jeevakanth Palaniappan Syncfusion Team July 15, 2021 10:23 AM UTC

Hi Hassan, 

Currently we don’t have support for this behavior. We have considered this requirement as a feature and logged a feature task Need to provide support for row footer template in datagrid” for this and added to our feature request list. Based on specific parameters including product vision and technological feasibility we will implement this feature. This will be available in any of our upcoming releases. Until then we appreciate your patience. 
 
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.   
 
 
Regards, 
Jeevakanth SP. 



KI KINS July 15, 2021 10:57 AM UTC

noted with thanks

I can manage below link till then further update,

https://www.syncfusion.com/kb/12665/blazor-grid-how-to-open-detailtemplate-while-clicking-anywhere-in-the-row 


but I would like to know below points to use this feature.


1.I need to show "details grid template" for current selected row only (other detail grid template should be collapse automatically)

2.How to hide arrow icon


for your reference. Please check attached file for better understanding




KI KINS July 15, 2021 01:14 PM UTC

noted with thanks

I can manage below link till then further update,

https://www.syncfusion.com/kb/12665/blazor-grid-how-to-open-detailtemplate-while-clicking-anywhere-in-the-row 


but I would like to know below points to use this feature.


1.I need to show "details grid template" for current selected row only (other detail grid template should be collapse automatically)

2.How to hide arrow icon.

3.Detail background color and main selected row should be same (light grey).

4.the left padding of detail grid and main grid row should be same


for your reference. Please check attached file for better understanding


Attachment: detailgrid_83c3d85.zip



KI KINS July 16, 2021 07:24 AM UTC

Please help because tomorrow support team will not available 



RS Renjith Singh Rajendran Syncfusion Team July 16, 2021 12:56 PM UTC

Hi Hassan, 

We have prepared a sample based on this scenario, please download the sample from the link below, 
 
References :  

Please find the suggestions for the queries below, 
 
Query 1 : 1.I need to show "details grid template" for current selected row only 
We can achieve this requirement by using Microsoft JSInterop. In the above sample, we have invoked the ExpandCollapseDetailRowAsync method of Grid in DetailDataBound event handler. By checking for target and args.data, we will be calling this method. Also, we have used DataBound handler to pass the dotnetreference to JS. By using this dotnetreference, we will be making call from JS to C#, during collapse action in Grid. This C# method will empty the target, when collapse action performed in Grid. 

Please refer the codes below, 


<GridEvents DetailDataBound="DetailDataBound" DataBound="DataBound" TValue="EmployeeData"></GridEvents>
public bool firstrender { getset; } = true;public async Task DataBound(){    if (firstrender)    {        var dotNetReference = DotNetObjectReference.Create(this);          // create dotnet ref        await Runtime.InvokeAsync<string>("detail", dotNetReference);     // send the dotnet ref to JS side        firstrender = false;    }}public async Task DetailDataBound(DetailDataBoundEventArgs<EmployeeData> args){    if (target != null)    {        if (target == args.Data)                              // return when target is equal to args.data        {            return;        }        await Grid.ExpandCollapseDetailRowAsync(target);    }    target = args.Data;} [JSInvokable("DetailCollapse")]                            // method called from JS when collapse is donepublic void DetailRowCollapse(){    target = null;                                // empty the target when collapse action is done }
public async Task RecordClickHandler(RecordClickEventArgs<EmployeeData> args) 
{ 
    await Grid.ExpandCollapseDetailRowAsync(args.RowData); 
} 

[detailexpand.js] 

var dotnetInstance; 
 
function detail(dotnet) { 
    dotnetInstance = dotnet; // dotnet instance to invoke C# method from JS  
} 
 
document.addEventListener('click'function (args) { 
    if (args.target.classList.contains("e-dtdiagonaldown") || args.target.classList.contains("e-detailrowexpand")) { 
        dotnetInstance.invokeMethodAsync('DetailCollapse'); // call C# method from javascript function 
    } 
}) 

 
Query 2 : How to hide arrow icon. 
We suggest you to apply the below style to achieve this requirement. 
 
<style>  
    .e-grid .e-detailrowcollapse .e-icons.e-dtdiagonalright.e-icon-grightarrow {  
        displaynone 
    }  
    .e-grid .e-detailrowexpand .e-icons.e-dtdiagonaldown.e-icon-gdownarrow{ 
        displaynone 
    } 
    ... 
</style>  
 
 
Query 3 : Detail background color and main selected row should be same (light grey). 
We suggest you to apply the below style to achieve this requirement. 
<style>  
    ... 
    .e-grid .e-detailcell, 
    .e-grid .e-detailindentcell, 
    .e-detailcell .e-grid .e-headercontent .e-headercell, 
    .e-detailcell .e-grid .e-gridcontent .e-rowcell{ 
        background#e6e6e6; 
    } 
    ... 
</style>  
 
 
Query 4 : the left padding of detail grid and main grid row should be same 
We suggest you to apply the below style to achieve this requirement. 

<style>  
    ... 
    .e-grid .e-detail-intent{ 
        width:0 !important; 
    } 
</style>  


Please get back to us if you need further assistance. 

Regards, 
Renjith R 



KI KINS July 18, 2021 04:59 AM UTC

I have issue on point no 1 ( 1.I need to show "details grid template" for current selected row only (other detail grid template should be collapse automatically) )

Please check my comments in below screencast

https://www.screencast.com/t/wCoFEhuyzoA.




JP Jeevakanth Palaniappan Syncfusion Team July 20, 2021 08:57 AM UTC

Hi Hassan, 

Thanks for sharing the video demo. We are able to reproduce the reported problem. We suggest you to use the below code to resolve your issue. 

<SfGrid @ref="Grid" DataSource="@Employees" Height="315px"> 
    <GridEvents RowSelected="RowSelectHandler" RowDeselected="RowDeselecthandler" OnRecordClick="RecordClickHandler" DetailDataBound="DetailDataBound" DataBound="DataBound" TValue="EmployeeData"></GridEvents> 
.. 
</SfGrid> 
 
@code{ 
 
    bool IsRowClickedTwice { get; set; } 
    public async Task DetailDataBound(DetailDataBoundEventArgs<EmployeeData> args) 
    { 
        if (target != null) 
        { 
            if (target == args.Data || IsRowClickedTwice)                              // return when target is equal to args.data 
            { 
               IsRowClickedTwice = false; 
                return; 
            } 
            await Grid.ExpandCollapseDetailRowAsync(target); 
        } 
        target = args.Data; 
    } 
    public void RowDeselecthandler(RowDeselectEventArgs<EmployeeData> args) 
    { 
        if (target == args.Data) 
        { 
            IsRowClickedTwice = true; //To ix issue When the same row is expanded, collapsed and then opening another row 
        } 
    } 
    public void RowSelectHandler(RowSelectEventArgs<EmployeeData> args) 
    { 
        //To ix issue When the same row is expanded, collapsed and then opening another row 
        target = args.Data; 
    } 
} 


Please get back to us if you have any other queries. 

Regards, 
Jeevakanth SP. 


Loader.
Up arrow icon