This is a migrated thread and some comments may be shown as answers.

Group IP addresses by subnet

3 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
apb
Top achievements
Rank 1
apb asked on 04 Dec 2008, 04:50 PM
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.

3 Answers, 1 is accepted

Sort by
0
Prangadj
Top achievements
Rank 1
answered on 08 Dec 2008, 01:15 PM
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
0
Accepted
Crescent
Top achievements
Rank 1
answered on 08 Dec 2008, 03:38 PM
> 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.
0
apb
Top achievements
Rank 1
answered on 08 Dec 2008, 08:38 PM
Thanks, Prangadj & Crescent.  I suspected it would be necessary to send back a subnet column, just hoped there was a better way.

-Al
Tags
Grid
Asked by
apb
Top achievements
Rank 1
Answers by
Prangadj
Top achievements
Rank 1
Crescent
Top achievements
Rank 1
apb
Top achievements
Rank 1
Share this question
or