how to remove particular element from an array at checkbox

I have a grid and many rows. For each row there is 1 check box where when I click on check box value should go to localvariable and when I unselect the check box that particular value should be removed.

a!checkboxField(
label: "",
choiceLayout: "COMPACT",
choiceLabels:"yes",
choiceValues: 1,
value: if(
fv!item.value = 0,
null,
fv!item.value 
),
required: false(),
saveInto: {
fv!item.value ,
a!save(
fv!item.isJointUtilized_int,

if(
fv!item.value = 1,
a!save(
local!checkbox,
append(
local!checkbox,
fv!item.othervalue
)
),
a!save(
local!checkbox,
rdrop(
local!checkbox,
1
)

)
)
},


),

Here value is getting appended into local!variable but while removing its removing last value in array. Not the one which is unselected. Can anyone help

  Discussion posts and replies are publicly visible

Parents
  • Yeah, I would put an index on each of the checkboxes, and if checked a!update() or insert() at the index, and if unchecked either a!update() or remove() at the index.  If you use a!update() you'd keep the skeleton of each CDT or whatever it is in your list, but you'd remove or blank out the contents, but leave the primary keys and structure and whatnot intact so you can easily put the data back when you check and uncheck the boxes.

    If you do insert() and remove(), you might have some problems.  Let's say you start with 5, {1,2,3,4,5}.  You remove the first, the second, and the third. {4,5}.  You want to add the third one back, so you insert at index 3, what results? {4,5,3}  That's not right.  Insert at index 2. {4,2,5,3}  You want to remove 3? {4,2,3}  Add it back? {4,2,3,3}  That's not even remotely what you want.  You can go through steps to make sure it doesn't do that, but keeping skeleton and just adding in and removing the contents into the "contents" field might be an easier way.

Reply
  • Yeah, I would put an index on each of the checkboxes, and if checked a!update() or insert() at the index, and if unchecked either a!update() or remove() at the index.  If you use a!update() you'd keep the skeleton of each CDT or whatever it is in your list, but you'd remove or blank out the contents, but leave the primary keys and structure and whatnot intact so you can easily put the data back when you check and uncheck the boxes.

    If you do insert() and remove(), you might have some problems.  Let's say you start with 5, {1,2,3,4,5}.  You remove the first, the second, and the third. {4,5}.  You want to add the third one back, so you insert at index 3, what results? {4,5,3}  That's not right.  Insert at index 2. {4,2,5,3}  You want to remove 3? {4,2,3}  Add it back? {4,2,3,3}  That's not even remotely what you want.  You can go through steps to make sure it doesn't do that, but keeping skeleton and just adding in and removing the contents into the "contents" field might be an easier way.

Children
No Data