I need to create a json string in controller which is as below and send it to view where it gets bind to my js code..
{
id: 'state',
label: 'State',
options: [
{ id: "AL", name: "Alabama" },
{ id: "AK", name: "Alaska" },
{ id: "AZ", name: "Arizona"}
],
valueSetter: function(rule, value) {
rule.$el.find('.rule-value-container select')[0].setValue(value);
}
}
Id, label and options are to be dynamically generated and I have done that using JObject and JArray as below..
JObject parameter1 = new JObject();
parameter1["id"] ="state";
//And so on...
The part in valueSetter is not dynamic but how do I generate something like this.
Any help is sincerely appreciated.
Thanks