Appframe Knowledge Base


1 hits
0

How to define a DataObject which reflects the contents of an Array

// Define the array containing the initial data 
var vArrayOfObjects = [
    { Type: "Issue" },
    { Type: "Suggestion" }
];

// Define the array data handler that uses the array we just declared
var vArrayDataHandler = new af.data.ArrayDataHandler(vArrayOfObjects, ["Type"]);

// Define the data object that uses the array data handler we just defined
var vArrayDataObject = new af.DataObject({
    dataHandler: vArrayDataHandler,
    selectFirstRow: false,
    fields: [{ name: "Type", type: "string" }]
});

// If you want to add items:
vArrayOfObjects.push({ Type: "Secret Type" });
vArrayDataObject.refreshDataSource();

// If you want to remove items:
vArrayOfObjects.splice(0, 1);
vArrayDataObject.refreshDataSource();

// If you want to modify items:
vArrayOfObjects[0] += " Item";
vArrayDataObject.refreshDataSource();

components web · Perma link post comment Posted by: Jan Henrik H. Meling (13-nov-2013)