Forums: How to sort IP addresses - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to sort IP addresses

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16361
  • Joined: 03-February 03
  • Gender:Male

Posted 13 March 2019 - 07:00 PM

This solution is MySQL specific. It will also work the same way in ASPRunner.NET and ASPRunnerPro.

Question:

I have a list IP addresses in my database. When I look at them in a list view they are not in order because of the format:

10.10.10.1
10.10.10.10
10.10.10.7
10.10.10.8
10.10.10.9

and so on. In my SQL query I can use INET_ATON(address) to change it to a whole number, however I can't get it to work for the list page.

Answer:


1. Add a calculated field to your SQL query:

select
...
INET_ATON(address) as addressN
...


2. Open the List page in Page Designer and switch your grid to Advanced. Add addressN field to the grid.
Then delete addressN field value element and address field header like on screenshot below.

Posted Image

Then move items and delete extra column to make the grid look nice. So now we displaying address field but sorting data by calculated field addressN. This technique can be applied to many other situations.
Best regards,
Sergey Kornilov
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

3 User(s) are reading this topic
0 members, 3 guests, 0 anonymous users