Group IP addresses by subnet

4 posts, 1 answers
  1. apb
    apb avatar
    4 posts
    Member since:
    Apr 2008

    Posted 04 Dec 2008 Link to this post

    Ok, I know this is a weird one:

    Is it possible (without returning multiple columns) to group IP addresses displayed in RadGrid by subnet?

    For example:
    1.1.1.1 - 1.1.1.255
    1.1.2.1 - 1.1.2.255
    1.1.3.1 - 1.1.3.255

    Thanks.
  2. Prangadj
    Prangadj avatar
    174 posts
    Member since:
    Jan 2008

    Posted 08 Dec 2008 Link to this post

    Why not using the grouping feature of the grid:

    http://demos.telerik.com/aspnet-ajax/Grid/Examples/GroupBy/OutlookStyle/DefaultCS.aspx

    or creating more advanced grouping expressions if needed:

    http://demos.telerik.com/aspnet-ajax/Grid/Examples/GroupBy/Expressions/DefaultCS.aspx

    Prangadj
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Crescent
    Crescent avatar
    20 posts
    Member since:
    Jul 2008

    Posted 08 Dec 2008 Link to this post

    > I know this is a weird one
    That's not weird at all. Rather clever. I can see that being pretty useful actually, if I was looking at data based on ip-addresses.

    Answer: you can't do groupings like that out of the box with vanilla data that only has an "IP" field. Ignore Prangadj's examples. The quickest implementation is to change the data you're returning to include a field with the ranges you are grouping on. So instead of just returning a field with "IP", you would also return a field "IPRange" that would contain the text value you're grouping on (eg "1.1.1.1-1.1.1.255"). Then just tell RadGrid to group on the "IPRange" field.

    The downside of doing it this way is you're sending extra data in each row that could easily be extrapolated from the remaining fields.  That may or may not be important to you. If it is, your second option would be to perform the calculations on the fly after receiving it from the db, but before binding it to the grid.
  5. apb
    apb avatar
    4 posts
    Member since:
    Apr 2008

    Posted 08 Dec 2008 Link to this post

    Thanks, Prangadj & Crescent.  I suspected it would be necessary to send back a subnet column, just hoped there was a better way.

    -Al
Back to Top