3

Is it possible to use a JavaScript function instead of a URL to fill a Flexigrid? The function I want to use returns a JSON object.

Artyom
  • 1,599
  • 12
  • 22
Chris
  • 1,610
  • 3
  • 18
  • 37

2 Answers2

0

Finally I found it.

You can call : FlexiGrid.flexAddData(myData);

var myRows = getRows();
var myData = { total: myRows.length , page: 1, rows: myRows  };    
flexiGrid.flexAddData(eval(myData));

The rows in myRows have to be normal flexigrid rows.

Chris
  • 1,610
  • 3
  • 18
  • 37
  • rohitszone's comment: "Could you Please post the function you have written to getRows() to have JSON Object ?? Also what do I mention for url parameter inside flexigrid call ?? Answers might be quite simple, am very new." – Peter O. Feb 18 '12 at 11:20
  • Hi Peter, getRows() has to return a JSON object like this: function getRows(){ return {[{"id":"1","cell":["row1, cell1","row1, cell2"]},{"id":"2","cell":["row2, cell1","row2, cell2"]}]}; } You can leave the url parameter empty. – Chris Feb 28 '12 at 15:06
-1

I think you can do that. Just call the java script method using from flex apis that return JSON object...

  1. write a JS method that return JSON object,
  2. List item from flex application call JS method using ExternalInterface.call(JSmethod) api (for more detail please refer to flex doc)
  3. List item create a ArrayCollection object by parsing JSON object using JSON.decode()
  4. List item set ArrayCollection object as the data source of the Grid.
majid
  • 66
  • 6