Int property sorting

Dean Everhart 1,541 Reputation points
2024-04-04T09:36:50.18+00:00

How do I get an int property to sort "normally?" 0, 1, 2 ,3...9, 10, 11... instead of the sort that is pictured in the first number below (below).

current sort in the view is being sorted by the following...

<script>

    $("#tbltrans").dataTable({

        order: [[0, 'asc']],

        "pageLength": 20

    });

</script>

I want to change the way the numbers (re: first number) sorts the view

User's image

Developer technologies | ASP.NET | ASP.NET Core
Microsoft 365 and Office | Development | Office JavaScript API
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

2 answers

Sort by: Most helpful
  1. Dean Everhart 1,541 Reputation points
    2024-04-04T10:54:46.9166667+00:00

    Solution

    create a hidden field/column as the first column of the view of the first int property of the two int property calculated field.

    e.g.
    IF Calculated Field =
    ExampleIntProptery1 + ExampleIntProperty2

    Create a hidden ExampleIntProptery1 column as the first column in the view.

                <th hidden>
                    @Html.DisplayNameFor(model => model.ExampleIntProperty1)
                </th>                
                                        /
                 <td hidden>
                        @Html.DisplayFor(modelItem => item.ExampleIntProperty1)
                 </td>
    
    1 person found this answer helpful.
    0 comments No comments

  2. Bruce (SqlWork.com) 81,981 Reputation points Volunteer Moderator
    2024-04-04T15:56:31.7966667+00:00

    you need to use a custom sorting plugin. see:

    https://datatables.net/plug-ins/sorting/

    you can build your own, if none of these do what you want.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.