I am working on an application that uses Xpages and KendoUI. In one particular page I have a tool bar with a button with "Add Record". The button opens a window and the user will select one from a piece of data and that will create a new record.
The list of data are employee names and I must compute them. I do so in a sessionScope [could be viewScope] array in the beforePageLoad, like so:
<xp:this.beforePageLoad>
<![CDATA[#{javascript:viewScope.myArray = [];
viewScope.myArray.push("1st Val");
viewScope.myArray.push("2nd Val");
viewScope.myArray.push("3rd Val");}]]>
</xp:this.beforePageLoad>
The dropdown needs data in the following format:
var data = [
{ text: "Black", value: "1" },
{ text: "Orange", value: "2" },
{ text: "Grey", value: "3" }
];
For the life of me I cannot get the data into that format. It looks like a javascript object to me.
How do I get the array in the viewScope into the format I need?
var o = {};
o = "#{javascript:viewScope.get('myArray');";