Multiple data columns for single Datagrid column

I've download your trial version and looking into your product for our company and was looking at the capabilities of the DataGrid. I'm trying to see if we can do the following.

Our data comes back from the DB in an employee class 

3 of the properties are EmployeeID, FirstName and LastName

In one of the columns we would like to build a link which redirects to the EmployeeInfo page for the given employeeID, and as the Link we want to display the full name 

So something like this

<a rel='nofollow' href="~/EmployeeInfo/?employeeID={EmployeeID}">{FirstName} + " " + {LastName}

But I can't figure out how to accomplish this using your control.

Thanks for any info.



7 Replies 1 reply marked as answer

JP Joseph Pacelli March 31, 2022 07:25 PM UTC

So I actually was able to figure it out and got it working.

This works fine and I get a grid of employees no problem.

The other thing I'm struggling with is if the user selects Photo Display

When they do this we would display 3 photos per line with information under each photo like

Name, Title, Division , Department, Hire Date.


Can you do this with DataGrid or is it a different control altog



JC Joseph Christ Nithin Issack Syncfusion Team April 1, 2022 01:37 PM UTC

Based on the provided information we suspect that you are having a image in one of your column. When you click on the image you want the row to expand and show a detailed template where you want to display 3 images with information like Name, Title, Division , Department, Hire Date etc. You can achieve this using the detailed template feature of the EJ2 grid. We have discussed about this in detail in the below documentation.


Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/grid/row/detail-template


Samplehttps://ej2.syncfusion.com/aspnetcore/Grid/DetailTemplate#/bootstrap5


If this is not your requirement, kindly share the following details so that we may be able to assist you in a better way.


  • Please explain your requirement in detail.
  • Share a video demo showing your requirement.
  • Share the complete grid rendering code, you are using.


Please get back to us for further details.



JP Joseph Pacelli April 1, 2022 05:21 PM UTC

So basically this would be the requirement. We are converting a Employee Directory classic ASP page to .NET Core.

The user can do a search based on a few parameters; First Name, Last Name, Department, Location

This displays the results which I was able to do fine with a DataGrid.

But the user can select a check box Display Photos. 

This is turn would do something like the following; 

With 3 photos per row and the employees info below their photo

Is this something you can do with DataGrid, or is this a different control. I'm in the process of evaluating your  product and this is the one thing I still need to determine if you have a control for.




RS Rajapandiyan Settu Syncfusion Team April 4, 2022 02:05 PM UTC

Hi Joseph,


Currently, we are validating your query, we will provide further details on or before 6th, April 2022. We appreciate your patience until then.


Regards,

Rajapandiyan S



JC Joseph Christ Nithin Issack Syncfusion Team April 5, 2022 02:34 PM UTC

We would like to get some more details on your requirement, please share the following details so that we may be able to provide a better solution ASAP.


  • As you have mentioned when you click on the check box Display Photos. Please ensure this check box is not the part of grid and it is an external check-box. And when you uncheck the checkbox you want to return back to the initial grid.
  • And you have also mentioned that the user can do a search based on a few parameters; First Name, Last Name, Department, Location. This displays the results which I was able to do fine with a DataGrid. Please share a screenshot of the DataGrid you are getting at the beginning.
  • Please share a screenshot of the page you get on initial rendering.
  • Please also confirm you are only rendering the grid only after you perform a search operation using an external control.
  • Also confirm if you want to display the photos of the employees in the same DataGrid which you display the data before clicking the checkbox.
  • Please share a sample of the data structure you are using.



We also want you to know that the DataGrid will be populated based on the fields used in the dataSource and we are not able to render the columns from a collection of array to perfectly render 3 objects of the array per row using DataGrid.


Please get back to us for further details.



JP Joseph Pacelli replied to Joseph Christ Nithin Issack April 5, 2022 06:19 PM UTC

So it's basically a page with 2 partial views

        <div id="print-area">

            @if (Model.DisplayPhotos)

            {

                <partial name="_EmployeePhotos" [email protected] />

            }

            else

            {

                <partial name="_SearchResults" [email protected] />

            }

        </div>

So the _SearchResults partial view is the DataGrid which works fine. The _EmployeePhotos is the other partial view which doesn't have to be a DataGrid if this wouldn't be the correct control to use. What I'm currently doing for this view is the following;

<tbody>

            @{

                var rowCount = 1;

                <tr>

                    @foreach(var item in Model.Employees)

                    {

                        string[] rel='nofollow' href = @item.FNLName.Split('|');

                        <td class='celltext' width='300'>

                            <a rel='nofollow' href="/"><img width="175" height="175" alt="User Photo Not found" loading="lazy" onerror="this.style.display = 'none'" [email protected] /></a>

                            <div class='celllabel'>Name: <a rel='nofollow' href="@rel='nofollow' href[0]">@rel='nofollow' href[1]</a></div>

                            <div class='celllabel'>Title: @item.JobTitle</div>

                            <div class='celllabel'>Dept: @item.Department</div>

                            <div class='celllabel'>Div: @item.Division</div>

                            <div class='celllabel'>Hire Date: @item.DateOfLastHire</div>

                        </td>

                        rowCount++;

                        @if (rowCount == 4)

                        {

                            rowCount = 1;

                            @:</tr><tr>

                        }

                    }

                </tr>

             }

        </tbody>

This works find but was wondering if you had a control which performed such a task. If not we still have this solution which works. 




JC Joseph Christ Nithin Issack Syncfusion Team April 6, 2022 04:30 PM UTC

Based on the provided information we could see that you having two partial views and when you check the check box you want to hide the data grid and show photos as a tile view containing 3 photos per row.


  We suggest you to use the Cards control with the tile view. Please refer the below demo and documentation for the tile view.


Demo: https://ej2.syncfusion.com/aspnetcore/Card/TileView#/fluent


Documentation: https://ej2.syncfusion.com/aspnetcore/documentation/card/getting-started

Please get back to us for further details.


Marked as answer
Loader.
Up arrow icon