1. Jon Stoller
  2. PowerBuilder
  3. Monday, 26 November 2018 02:09 AM UTC

I am running PowerBuilder 2017.  The database is Microsoft SQL Server. 

I am doing something very simple but it is not working.   

I have a column in a datawindow and the column has a drop down datawindow. I want to sort the drop down in a certain order but it doesn't sort.  I have done this thousands of times before without a problem, but now I am having a problem this one time (I think).  What could cause this?  What can I do to fix it. 

If this was a datawindow in a Window or User Object I would use SetSort and Sort to force it to be in the correct order.  However, in this case the data is used in a drop down data window.  I don't know how to put something into the code to force the dropdown to be in the order I want. 

Here is some more information:  The drop down is very simple.  The data comes from one table - "inventory_item".  The table has several columns but I am only using 2 columns in the drop down - item_no and item_desc1.  The primary key is item_no.  I want the drop down to list in order of item_desc1. 

I already had a datawindow that was in order by item_no.  I copied it and changed the sort to item_desc1.  I tried to define it in graphic mode and with syntax.  It isn't working either way.  Any ideas?

Thank you for any help with this. 

Jon Stoller

jon@akaware.com

973-720-8211

René Ullrich Accepted Answer Pending Moderation
  1. Monday, 26 November 2018 06:27 AM UTC
  2. PowerBuilder
  3. # 1

If you specified the sort order in the datawindow object that you use as DDDW the data should be ordered after retrieve.

If you want to set the sort order at runtime you can do it with the datawindow child:

DataWindowChild ldwc_dddw

IF GetChild ("your_dddw_column", ldwc_dddw) = 1 THEN

   ldwc_dddw.SetSort ("your sort definition")

   ldwc_dddw.Sort ()

END IF

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 26 November 2018 20:57 PM UTC
  2. PowerBuilder
  3. # 2

Throw the current DDDW object out and start over.

Use the DW Painter to create your DDDW.
Use the ROWS/SORT option to specify your desired sort order.
Save.
Exit the painter and regenerate.
Get back into the painter and  test.

Sometimes the only way to fix it is to toss it and just start over.


Good Luck,

Olan

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Monday, 26 November 2018 21:34 PM UTC
  2. PowerBuilder
  3. # 3

If the DataWindow object has a sort order in the SQL or has DataWindow sorting set, it should appear in that order.

You should make note that the DropDownDataWindow is only retrieved once and therefore is the same for every row. If you attempt to sort it in code using GetChild as suggested, it will only work if there is one order.

Comment
There are no comments made yet.
Govinda Lopez @Appeon Accepted Answer Pending Moderation
  1. Monday, 26 November 2018 23:28 PM UTC
  2. PowerBuilder
  3. # 4

I agree with the suggestions here. You have 2 easy ways to do it:

 

  1. Directly on the DataObject of your DDDW at design time (DW Designer).
  2. During runtime. In this case you would need to get the DWChild and Sort it with the SetSort() and Sort() methods.

 

It mostly depends on your needs. If your app needs to be dynamic, then the option 2 would be your candidate. Now, just consider that these two are not the only options you have. But maybe getting in to too much detail could make this post bulky. Unless, of course, you actually require something more elaborate. 

 

 

Regards,

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.