Adding sort capabilities to LinkEditor (link_ed.dxl)

I have been using the wonderful dxl script called LinkEditor (link_ed.dxl) for some time now. One of the things that I would like to do is be able to sort on the different columns, so to group all the in links together or sort by link module, etc. I've looked at the DXL help manual. This seems like it should be easy, but I haven't been able to figure out how to add sort functionality. Any help would be appreciated.
ZenMonkey760 - Wed Oct 24 13:53:39 EDT 2012

Re: Adding sort capabilities to LinkEditor (link_ed.dxl)
llandale - Wed Oct 24 16:58:13 EDT 2012

ListView yes?

Your DBE ListView needs to be created with this "option":

  • listViewOptionSortText


You need a function almost identical to this:

 

//***************************************************
int    fDbeLv_clbkSortFunction(string s1, s2)
{     // Standard sort function when defining a ListView column as sortable.
        // Developers Note: Some code if added herein will cause DXL exception Violations.
        //      Don't understand why, but this function needs to be kept as-is.
        int     Result
        if     (s1 == s2) Result =  0
        elseif (s1 >  s2) Result =  1
        elseif (s1 <  s2) Result = -1
        else{} // all cases covered
        return(Result)
}  // end fDbeLv_clbkSortFunction()


After realizing the dialog and defining the column, use something like this to allow sorting of that column:

 

 

  • if (in_AllowSorting) set(in_dbeListView, in_ColNum, fDbeLv_clbkSortFunction) // Allow sorting this column


The user can sort the column (ascending only) by clicking on the column header, and your program can force sorting on a column with this:

 

 

  • setSortColumn(DBE listView, int columnIndex)


-Louie

In my limited experience with List Views I note that is is FAR easier to define columns lower-to-higher which is left-to-right. e.g. define column #0; then #1. You CAN go right to left by always inserting new column #0 which pushes the others to the right, but it also re-numbers them which is hard to manage.

 

Re: Adding sort capabilities to LinkEditor (link_ed.dxl)
ZenMonkey760 - Wed Oct 24 17:30:33 EDT 2012

llandale - Wed Oct 24 16:58:13 EDT 2012

ListView yes?

Your DBE ListView needs to be created with this "option":

  • listViewOptionSortText


You need a function almost identical to this:

 

//***************************************************
int    fDbeLv_clbkSortFunction(string s1, s2)
{     // Standard sort function when defining a ListView column as sortable.
        // Developers Note: Some code if added herein will cause DXL exception Violations.
        //      Don't understand why, but this function needs to be kept as-is.
        int     Result
        if     (s1 == s2) Result =  0
        elseif (s1 >  s2) Result =  1
        elseif (s1 <  s2) Result = -1
        else{} // all cases covered
        return(Result)
}  // end fDbeLv_clbkSortFunction()


After realizing the dialog and defining the column, use something like this to allow sorting of that column:

 

 

  • if (in_AllowSorting) set(in_dbeListView, in_ColNum, fDbeLv_clbkSortFunction) // Allow sorting this column


The user can sort the column (ascending only) by clicking on the column header, and your program can force sorting on a column with this:

 

 

  • setSortColumn(DBE listView, int columnIndex)


-Louie

In my limited experience with List Views I note that is is FAR easier to define columns lower-to-higher which is left-to-right. e.g. define column #0; then #1. You CAN go right to left by always inserting new column #0 which pushes the others to the right, but it also re-numbers them which is hard to manage.

 

Thanks Louie! I have, thanks to a lot of trial and error, got the sorting to work using this method you suggest. The sorting works great by clicking on the headers for the columns.

I've attached the updated LinkEditor DXL.

Here's another silly question: How would I update this script to add a second level sort order (e.g. sort by Module then by ID or sort by In/Out then by Object Heading/Text, etc.)
Attachments

attachment_14901662_LinkEditor-Sort.dxl

Re: Adding sort capabilities to LinkEditor (link_ed.dxl)
llandale - Thu Oct 25 14:45:12 EDT 2012

ZenMonkey760 - Wed Oct 24 17:30:33 EDT 2012
Thanks Louie! I have, thanks to a lot of trial and error, got the sorting to work using this method you suggest. The sorting works great by clicking on the headers for the columns.

I've attached the updated LinkEditor DXL.

Here's another silly question: How would I update this script to add a second level sort order (e.g. sort by Module then by ID or sort by In/Out then by Object Heading/Text, etc.)

Well if you want the primary sort to be my Module name and secondarily by Object ID (i.e. all objects of a module appear together; and within a module sorted by ID) then all you need to do is perform individual sorts in reverse order of precedance; first sort by Object ID and then my Module Name. User can do that manually but you could also have a callback button that does that for them.

-Louie

Re: Adding sort capabilities to LinkEditor (link_ed.dxl)
SystemAdmin - Wed Mar 20 00:08:36 EDT 2013

Hello,

I wrote a script that is based on "link_ed.dxl" I added additional features and additional data validation. It's still a work in progress but was wondering if anyone would have additional feature requests? If you note any logic error please let me know. Thank you.

-Jim
Attachments

attachment_14958844_transferLinksAv_1_0A.dxl

Re: Adding sort capabilities to LinkEditor (link_ed.dxl)
m_estock - Thu Sep 05 17:50:12 EDT 2013

ZenMonkey760 - Wed Oct 24 17:30:33 EDT 2012
Thanks Louie! I have, thanks to a lot of trial and error, got the sorting to work using this method you suggest. The sorting works great by clicking on the headers for the columns.

I've attached the updated LinkEditor DXL.

Here's another silly question: How would I update this script to add a second level sort order (e.g. sort by Module then by ID or sort by In/Out then by Object Heading/Text, etc.)

First of all, thank you for all the hard work in making this script.

 

The one problem I am having with it is this:

When I sort a column and then choose a link to revert, the script will not revert the link I have selected. Instead it is reverting the link that would have been in that position before I sorted the column, if that makes sense. I have no dxl background so I'm not sure what the issue is. This script would be perfect if this could be fixed though. Any ideas?

 

Thanks

-Matt

Re: Adding sort capabilities to LinkEditor (link_ed.dxl)
llandale - Fri Sep 06 11:56:23 EDT 2013

m_estock - Thu Sep 05 17:50:12 EDT 2013

First of all, thank you for all the hard work in making this script.

 

The one problem I am having with it is this:

When I sort a column and then choose a link to revert, the script will not revert the link I have selected. Instead it is reverting the link that would have been in that position before I sorted the column, if that makes sense. I have no dxl background so I'm not sure what the issue is. This script would be perfect if this could be fixed though. Any ideas?

 

Thanks

-Matt

Yes.  You need to add another column to the listview, perhaps "Orginal Sequence" of type "int" perhaps column 5.  Then in function "DoRevert" after current line 274 ("if (selected..)") then getColumnValue(5), and use variable instead of "index" in line 275.

Sorry, don't have time to code this.

-Louie