Here I have a dropdown for that data I have fetch from the database
so the output is dataset....for that I have converted into label and value by script on transform
while rederiving the data I the label data doesn't populate
thanks in advance
so the output is dataset....for that I have converted into label and value by script on transform
while rederiving the data I the label data doesn't populate
thanks in advance
Remove the transform. You don't need it here, your query already returns a list of value
and label
.
If you don't want your 'options' to be a dataset, you can just change the return type of the query binding to json
.
But let's fix that transform script anyway, for learning sake.
Let's imagine your query doesn't return 'label' and 'value' but 'name' and 'val', and some other columns you don't want.
With query return type set to dataset, and returning a dataset (could be made shorter, but for simplicity's sake I made every step explicit):
label_index = value.getColumnIndex('name')
value_index = value.getColumnIndex('val')
headers = ['label', 'value']
data = zip(
value.getColumnAsList(label_index),
value.getColumnAsList(value_index)
)
return system.dataset.toDataSet(headers, data)
With return type set to json, and returning an array of objects (json like):
return [
{
'label': row['name'],
'value': row['val']
} for row in value
]
Oh and there's something I forgot to mention:
At the end of your transform, you set the self.props.options
, and then return them.
That's not how binding work.
The property that has the binding will receive the value returned. You don't need to set it manually.
so, instead of
self.props.options = x
return self.props.options
you should do
return x
ok thank you for making me aware of it , let me try this logic too.
the issue is resolved.
Solution : while retrieving the data in a dataset and converted into list so the value datatype changed as string by casting it into int .it's working (EX: int(data))