Okay
  Public Ticket #3271330
IP Addresses
Closed

Comments

  • Scott started the conversation

    Can i sort IP Addresses correctly? i.e.,

    10.250.11.0
    10.250.11.11
    10.250.11.180
    10.250.11.241
    10.250.11.242
    10.250.11.61
    10.250.11.62
    10.250.11.63
    10.250.11.66
    10.250.11.71
    10.250.11.72

    You can see above, .180 .241 .242 list before .61

    Is there a way to get these to list,

    10.250.11.0
    10.250.11.11
    10.250.11.61
    10.250.11.62
    10.250.11.63
    10.250.11.66
    10.250.11.71
    10.250.11.72

    10.250.11.180
    10.250.11.241
    10.250.11.242


    Thanks, Scott

  • Scott replied

    In my desired result, HTML double-space added an extra blank line between .72 and .180.   That's a typeO. i'm just looking for the host part of the IP to be in numerical order.

  •  1,849
    Miloš replied

    Hi, Scott.

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -

    I am honestly not sure at all if we have a valid solution for this use-case with our current plugin's capabilities.

    We will ask our 2nd level Team if they know of any possible workaround that we might suggest.

    As soon as they respond we will report back, and i will let you know if we need further details from your end.

    Thank you for your patience.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  1,849
    Miloš replied

    Hi, Scott.

    We checked, and with our current plugin capabilities, we don't have an easy built-in solution to achieve this kind of sorting,

    because in String columns, they get stored in the database as "VARCHAR" data type and have alphabetical sorting,

    while in your use-case, you need the sorting to behave as for numerical data.

    Some custom workaround ideas can be found online.

    For example, on this page, you can see how you can try a 'PARSENAME' SQL function to get the different parts of an IP address value.

    ( For this to work, you will need an SQL Query based table)

    Their initial SQL table output was like this :

    IPAddress       
    --------------- 
    10.0.0.1
    192.120.40.243
    207.46.199.60
    255.255.0.0
    255.255.255.255
    64.233.188.15
    65.54.152.142
    65.97.176.172
    68.142.197.0
    98.123.251.21

    Then in their example of the following 'SELECT' statement will return the IP addresses sorted by their numeric value instead of by the 'VARCHAR' value:

    SELECT [IPAddress] FROM [WorkStation]
    ORDER BY CAST(PARSENAME([IPAddress], 4) AS INT),
             CAST(PARSENAME([IPAddress], 3) AS INT),
             CAST(PARSENAME([IPAddress], 2) AS INT),
             CAST(PARSENAME([IPAddress], 1) AS INT)

    The output of this SELECT statement is the following, which sorts the IP addresses as required.

    IPAddress       
    --------------- 
    10.0.0.1
    64.233.188.15
    65.54.152.142
    65.97.176.172
    68.142.197.0
    98.123.251.21
    192.120.40.243
    207.46.199.60
    255.255.0.0
    255.255.255.255

    -

    But, our plugin is based on an SQL Parser, which has an issue with sorting if you use "ORDER BY" as part of an SQL Query based table directly from our plugin,

    because wpDataTables plugin is adding "ORDER BY" dynamically based on what is set to be the default sorting column.

    And I'm not sure if 'PARSENAME' is going to work well directly in our SQL parser in this use-case.

    So my advice will be, try preparing a MySQL VIEW (which will return the data that you need), call it e.g. “view1” and then build a wpDataTables based on a simple query like

     "SELECT * FROM view1″.

     If you need help with using a VIEW in our plugin, you can see our video, where we show an example.

    -

    Please note: Using the SQL plugin feature requires at least a basic knowledge of SQL. It is assumed that you can create the table in some MySQL data manager (e.g., PHPMyAdmin, MySQL Workbench), and prepare a SQL query that will return the data you need. 

    Please be advised that writing custom SQL Queries or debugging Queries does not fall under what our support covers.

    You can check out this official page of WP codex,  for help with writing custom Queries.

    Let us know if that helped.

    If you get the output as intended, but if you see any issue with sorting on the resulting table in our plugin,

    you can try to disable the Sorting option for that wpDataTable and then users on front-end won't be able to change the sorting, but it should sort properly on initial load.

    I am not 100% sure if all of this will work perfectly, but if you try, let me know how it goes,

    we will do our best to advise you as much as possible.

    Thank you

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Scott replied

    Just in case this helps someone else,

    An easy solution for me turns out that if i simply make the host bit (xxx.xxx.xxx.HOST) a 3 digit number, it sorts in the correct order i need.   So in other words,  in stead of,

    10.250.11.0
    10.250.11.11
    10.250.11.180
    10.250.11.241
    10.250.11.242
    10.250.11.61
    10.250.11.62
    10.250.11.63
    10.250.11.66
    10.250.11.71
    10.250.11.72

    i use,

    10.250.11.000
    10.250.11.011
    10.250.11.061
    10.250.11.062
    10.250.11.063
    10.250.11.066
    10.250.11.071
    10.250.11.072

    10.250.11.180
    10.250.11.241
    10.250.11.242

    Things then sort correctly (for my situation).    If your subnet/s are wider you might need to use 3 digits in the network portion of the address too.    


    Here's another idea,

    If you had a data type of IP or IPv4, it could automatically either treat,

    10.250.11.2   as  010.250.011.002
    or automatically add the necessary zeros.

    Then sorting would work.

  •  1,849
    Miloš replied

    Hey, Scott.

    Thank you so much for sharing these possible solutions with us, and other users who might come across this ticket can use it as well.

    Of course, please also don't hesitate to open new tickets for anything else that might come up,

    as we like to keep one subject per ticket for more effective support.

    Thanks again!

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables