0

I am very new to ASP.NET Core MVC in C#. I have 2 datagrids or data table in a window arranged horizontally. I have some buttons arranged between the 2 grids.

How to create a UI as shown below? Please help me. It is in the Razor .cshtml view.

enter image description here

Something like this:

<div class="card-body">
    <table class="table display table-bordered" id="DATATABLE"> 
    </table>
</div>

1 Answer 1

1

You could try this code:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>@ViewData["Title"]</title>
    <link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
    <style>
        .container {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            margin: 20px;
        }

        .datagrid {
            flex: 1;
            margin: 10px;
            border: 1px solid black;
        }

        .buttons {
            display: flex;
            flex-direction: column;
            justify-content: center;
            margin: 10px;
        }

            .buttons button {
                margin: 5px 0;
            }

        .footer-buttons {
            display: flex;
            justify-content: space-between;
            margin: 10px;
        }

        .textbox {
            margin: 10px;
        }

            .textbox input {
                width: 100%;
            }
    </style>
</head>
<body>
    <div class="textbox">
        <input type="text" placeholder="Text box" />
    </div>
    <div class="container">
        <div class="datagrid" id="datagrid1">
            <table id="table1" class="display table-bordered" style="width:100%">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Position</th>
                        <th>Office</th>
                        <th>Age</th>
                        <th>Start date</th>
                        <th>Salary</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Tiger Nixon</td>
                        <td>System Architect</td>
                        <td>Edinburgh</td>
                        <td>61</td>
                        <td>2011/04/25</td>
                        <td>$320,800</td>
                    </tr>
                    <tr>
                        <td>Garrett Winters</td>
                        <td>Accountant</td>
                        <td>Tokyo</td>
                        <td>63</td>
                        <td>2011/07/25</td>
                        <td>$170,750</td>
                    </tr>
                    <!-- Add more rows as needed -->
                </tbody>
            </table>
        </div>
        <div class="buttons">
            <button id="button1">Button1</button>
            <button id="button2">Button2</button>
            <button id="button3">Button3</button>
        </div>
        <div class="datagrid" id="datagrid2">
            <table id="table2" class="display table-bordered" style="width:100%">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th>Position</th>
                        <th>Office</th>
                        <th>Age</th>
                        <th>Start date</th>
                        <th>Salary</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Ashton Cox</td>
                        <td>Junior Technical Author</td>
                        <td>San Francisco</td>
                        <td>66</td>
                        <td>2009/01/12</td>
                        <td>$86,000</td>
                    </tr>
                    <tr>
                        <td>Cedric Kelly</td>
                        <td>Senior Javascript Developer</td>
                        <td>Edinburgh</td>
                        <td>22</td>
                        <td>2012/03/29</td>
                        <td>$433,060</td>
                    </tr>
                    <!-- Add more rows as needed -->
                </tbody>
            </table>
        </div>
    </div>
    <div class="footer-buttons">
        <button id="buttonCancel">Button Cancel</button>
        <button id="buttonOK">Button OK</button>
    </div>

    <script>
        $(document).ready(function () {
            $('#table1').DataTable();
            $('#table2').DataTable();
        });
    </script>
</body>
</html>

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.