locked
Page pagination with model mvc Core RRS feed

  • Question

  • User-1422983141 posted

    I have a view that has a model that already supplies all the chart url for each chart in a table.

    <a href=@item.TradingChartUrl target="_blank">@item.Name</a>

    Instead of clicking each link in the table I would like to use a pagination to do the job for me.

    <div class="col-md-12">
                <nav aria-label="Page navigation example">
                    <ul class="pagination">
                        <li class="page-item"><a class="page-link" href="#">Previous</a></li>
                        <li class="page-item"><a class="page-link" href="#">1</a></li>
                        <li class="page-item"><a class="page-link" href="#">2</a></li>
                        <li class="page-item"><a class="page-link" href="#">3</a></li>
                        <li class="page-item"><a class="page-link" href="#">Next</a></li>
                    </ul>
                </nav>
            </div>

    My thought is that when I come back from the _blank page and want to look at the next chart I have to find the last link I 

    clicked on but I feel that the pagination could just give me the last and next chart?
     

    Friday, August 16, 2019 8:00 AM

Answers

  • User711641945 posted

    Hi kvic,

    Could you please give me the effect diagram you want or show more of your code, so that we can better understand your requirements.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 21, 2019 1:20 AM

All replies

  • User711641945 posted

    Hi kvic ,

    From your description, I think your issue could not be solved by pagination.For you want to get the data of the next item instead of the data of the next page. Paging is mainly used to display relatively small amounts of data, allowing users to see relevant information more concisely and intuitively.

    You could refer to the following documentation for specific pagination usage and purpose:

    https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/sort-filter-page?view=aspnetcore-2.2

    Best Regards,

    Rena

    Monday, August 19, 2019 6:51 AM
  • User-1422983141 posted

    I could use sever calls to create the next chart link but I have a model that already creates the page with a table of links to charts.

    I don't want to group or sort the data.

    I would have thought you could, with jscript, find all the a tags with the same id and loop through them, but I really don't know because I don't know enough about jscript.

    I can handle this with sever calls but I wanted to know if you could preform the same on the client without sever calls.

    Nice link and I will use it if I can't find another solution, but that's what this forum is about, asking and research first!

    <div class="table-responsive table-hover">
                    <table class="table table-sm table-striped table-default">
                        <caption>
                            <nav aria-label="breadcrumb">
                                <ol class="breadcrumb">
                                    <li class="breadcrumb-item"><a asp-area="Trade" asp-controller="Trade" asp-action="Index">Back</a></li>
                                    <li class="breadcrumb-item active" aria-current="page">Companies</li>
                                    <li class="breadcrumb-item"><a asp-action="Create">Add Company</a></li>
                                </ol>
                            </nav>
                        </caption>
                        <thead>
                            <tr>
                                <th>
                                    @Html.DisplayNameFor(model => model.CompanyName)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.TradingChartUrl)
                                </th>
                                <th>
    
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @foreach (var item in Model)
                            {
                                <tr>
                                    <td>
                                        <a href=@item.HomePageUrl target="_blank" style="text-transform:uppercase">@item.CompanyName</a>
                                    </td>
                                    <td>
                                        <a href=@item.TradingChartUrl target="_blank">@item.Name</a>
                                    </td>
                                </tr>
                            }
                        </tbody>
                    </table>
                </div>

    Monday, August 19, 2019 7:13 AM
  • User711641945 posted

    Hi kvic,

    Your code is incomplete and i could not reproduce your issue.

    1.Could you share the detailed code of your controller action and view?

    2.Could you share a simple picture to show the result you want?

    3.I come from this case.Are the requirements in these two threads consistent?

    Best Regards,

    Rena

    Monday, August 19, 2019 10:01 AM
  • User-1422983141 posted

    It is just that simple for this page

    A list of favorite Stocks, the Company name, and the link to open a chart on a _blank page.

    I can create a pagination from the model but I didn't want too, don't need help with doing that.

    But it looks like that is my only choice?

    Thanks anyway

    Monday, August 19, 2019 10:25 AM
  • User711641945 posted

    Hi kvic,

    Could you please give me the effect diagram you want or show more of your code, so that we can better understand your requirements.

    Best Regards,

    Rena

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 21, 2019 1:20 AM