Skip to main content

We have a SQL Server table that is a Code table.  Meaning this table contains a list of values for a drop-down list.  We have a column on this table called SequenceNumber - used to control the order that the rows are displayed in a drop-down list.

 

We want to create a SmartForm to maintain this table.  We would like to list the rows in SequenceNumber order.  We would like to have the ability to renumber the rows on the SmartForm.  What I have in mind is a button to move the row down in the list.  And another button to move the row up in the list.  If we moved SequenceNumber 3 up in the list, then the row that was SequenceNumber 2 would become SequenceNumber 3.

 

Does anyone know if doing something like this is possible in SmartForms?  We don't have to do it exactly like I described. 

 

Thanks for any suggestions you have.

Hi Terry

 

You need to create a List View from the Code table SmartObject. On the View's initialize rule there will be a statement to execute the view's list method. When you configure this rule you have the option to set the order in the Sort tab. If you select the "Sequence No" column in this tab your data will be sorted by that field.

 

Have a look at SmartForms Help for info on how to create List Views.

 

I think you will find it very hard to try and re-sequence the data using smartforms rules. What I would suggest is creating a stored procedure on your SQL server (if you have permission) that does the re-sequencing for you, and then expose this as a smartobject method. This procedure would accept the sequenceNo that you are moving and the direction and then peform the logic to re-sequence. You can then allow the user to select a row in the list and click the up or down button (toolbar buttons) to move the row. You will need to run the list refresh action after each move. 

 

If you need help on exposing a stored procedure as a smartobject method let me know.


Thanks.  You're idea of using a stored procedure sounds like a good idea.  I will try that.

 

I


Is there a way to keep the row that was moved up or down selected?

 

Example, I click on a row.  Then click on the button to move it up in the list.  My smartobject updates the database and then I redisplay the list with my row moved up.  But my row is no longer selected.  So before I can move it up another spot, I have to click the row again.  Is there a way to leave it selected?


Hi Terry

 

I am not aware of a way to keep the row selected after you refreshed the list.


Reply