Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
how to move item up or down in DCT select box ?
Opeth
Requirment:
It's DCT select box where in the select box I will be able to select an item and can move Item up or down. The requirment is to implement with Form api no cgi-callout.
Any help will be apriciated.
Thanks
Find more posts tagged with
Comments
nipper
OK, I am confused.
You have a set of options in a check box and you want to have the checked box move up or down ? Can you post a screenshot of the DCR ?
Reordering a set of options is pretty straightforward. It is a pain because you have to keep track of what is selected but you can do it without too much trouble.
Now you also have an issue of opening an existing DCR, if you have A,B,C and select C and move it it, when you open the DCR again it will be A,B,C unless you do some creative coding.
Opeth
It's a select box not a check box. ex:
Manage Tags Up
I am registering the callout by
IWEventRegistry.addItemHandler('/itemPath/Up', 'onCallout', moveUp);
Basically I am looking for the psudo code of achieving this task.
nipper
I have done it. It is a serious pain. This will take a lof of code.
Just in the current instance of a DCR, it is not that bad.
onitemchange (up/down I used checkboxes they look best) - clear checkbox, read list (all items and select item) into an array, move up/down, build new array and setoptions on list marking the selected item(s) as selected.
If you want the list to be arranged correctly when you edit the DCR (after it was moved and saved) then it gets considerably more difficult.
You need to keep 2 hidden lists (one for value one for label) reorder those when you reorder the primary, and select all everytime.
Then when you edit an existing DCR, you read the values & labels and build the list(again keeping track of what was selected and marking them as such)
This also implies your main list will be dynamic and not hard coded in the DCT, you will need a callserver or something to build it.
olap.jpg
Opeth
Hmmm.......What will be the estimation for to build this code?
nipper
Someone who *really* knows their stuff, 1 week to write 1 week to test.
There are a bunch of moving parts and a *lot* of places where it can break. Extensive testing is critical
ACheethayil
You can achieve it a little bit of javascript coding.
Say U have elements [A,B,C] in position 0,1,2 as follows.
0-A
1-B
2-C
You would like to move C[position 2 element] to position of B[position 1].
Only you have to do is define UP and DOWN functions,
and reswap the position of selected element.
In this case "get the position of C and do a (index -1)
(ie 2-1, is 1) and the element of postion will move to the position of our initially selected 2. So the revised position is as follows
0-A
1-C
2-B