AnsweredAssumed Answered

extjs grid + json+ webscript

Question asked by marcuzzo86 on Aug 10, 2009
Latest reply on Aug 11, 2009 by marcuzzo86
hi guys i have a question for you.
i'm trying to retrieve data from alfresco via webscript and then put it in a ExtJS grid.
my webscript work fine, these are :
- descriptor file:
  <description>Lists all documents with type: FATTURA ATTIVA</description>
  <format default="json">extension</format>

- free marker template file:
   total: ${total},
   rows: [
   <#list nodes as document>
           {"id": "${document.nodeRef}", "name": "${}"}

-and javascript file:
var type='TYPE:"{}fatt_a"';
nodes = search.luceneSearch(type);

var start = 0;
var limit = 100;

if (args.start != undefined) {
   start = args.start;

if (args.limit != undefined) {
   limit = args.limit;

pagedResults = new Array();
for (i=0; i < nodes.length && i < limit; i++ ) {
   var node = nodes[(+start + i)];
   if (node != undefined) {

model.nodes = pagedResults; = nodes.length;

how can you see it is a very simple webscript that return a list of document.
the view files are these:

-the javascript file that ask alfresco and then create the grid:

Ext.onReady(function() {
var record =[ //definisco la forma del record
    {id: 'id', name: 'name'},                 

var myReader = new{
    totalProperty: "total",             // numero righe
    root: "rows",                         // lista dei dati da esporre (label del file json)
}, record);

   var grid = new Ext.grid.GridPanel({
      store: new{
                 // load using HTTP
            proxy: new{url: 'http://localhost:8080/alfresco/service/opsoro/search'}), //effettuo al richiesta
            reader: myReader //oggetto JSONreader
      columns: [
         {header: 'ID', width: 120, sortable: true, dataIndex: 'id'},
         {header: 'Name', width: 120, sortable: true, dataIndex: 'name'},
      viewConfig: {
         forceFit: true
      renderTo: 'content',
      title: 'mannaggia de la pulchiacchera!!!!',
      width: 500,
      height: 500,
      frame: true


- and the html:
    <!– Include Ext and app-specific scripts: –>
    <script type="text/javascript" src="../adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="../ext-all-debug.js"></script>
    <script type="text/javascript" src="griglia.js"></script>
    <!– Include Ext stylesheets here: –>
    <link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css">
    <link rel="stylesheet" type="text/css" href="griglia.css">
   <h1>Griglia dinamica</h1>
   <div id="content">


The html return an empty grid! what is the problem?????? thanks!