Hello everybody,
I need help on working with dataset, I have a dataset which consist one of the column as Index to which I want to pass alternatingly value 1 ( each row in Index column would be 0,1,0,1,0,1…) so when ever user makes a new entry it will automatically assign value either 0 or 1
Intention is I will be using a template in a template repeater and each template text will either be blue or white depending on 0 or 1 pass through Index Column template parameter.
I have tried following script but i only updates last index as shown in snapshot, I doubt that issue is with system,dataset.toDataset instruction, its not getting executed for each value of (i). I am a newbie in python programming and just taking baby steps.
Note : pls ignore Value 2 in last dataset entry it was old snap latest is 1 as sen in scripting snap
ds = event.source.parent.getComponent('Template Repeater').templateParams
ds_new = system.dataset.sort(ds, 1)
for i in range(ds_new.rowCount):
ds_new = system.dataset.setValue(ds_new, i, 'Index', i % 2)
event.source.parent.getComponent('Template Repeater').templateParams = ds_new
Ps. you should always update your GUI after you’ve finished changing values to avoid constant updates
I mean, in my code it was updating 1 only in last dataset entry so i was suspecting query was executing only during last (i) entry
I am aware of modulus function but as mentioned un system.dataset.setdataset script, I was thinking i need to execute though alternate (i) dataset entry and pass 1 as stated in Argument example.
Because in your code you were never updating ‘data’ in the while loop, so you were always using the original dataset to set the next value and then writing that over GUI dataset. So the only update you saw was the last.