Problem when try to create live search in gridPanel

January 6th, 2009
  • Hi,
    I new with extjs, and i have some problem with the live search option,
    i understand how to build the live search when the data of the grid is from some server,
    but when i trying to build live-search of the grid with a local data (an array) i fail.

    can anyone pls help?


  • Ok, (:


    var GridUI = function() {

    var ds; //hold our data
    var grid; //component
    var columnModel; // definition of the columns
    var search;

    var myData = [['bla bla','daadada','adfaaf','dqadaf'],
    ['badafla bla','dadeeada','addaaf','dadfaf'],
    ['blfksafa bla','daqqdada','adaaaf','daadaf'],
    ['bla blasfsa','dadsdada','adaaaf','dadfaf'],
    ['blaksjfks bla','dffadada','adaqaf','dsadaf']];

    function setupDS(){
    ds = new Ext.data.Store({
    proxy: new Ext.data.MemoryProxy(myData),
    reader: new Ext.data.ArrayReader(
    {},
    [
    {name: 'description'},
    {name: 'context'},
    {name: 'priority'},
    {name: 'duedate'}
    ]
    )

    });
    ds.load();
    }

    function getColumnModel() {
    if(!columnModel) {
    columnModel = new Ext.grid.ColumnModel(
    [
    {
    header: 'Description',
    width: 250,
    sortable: true,
    dataIndex: 'description'
    },

    {
    header: 'Context',
    width:100,
    sortable: true,
    dataIndex: 'context'
    },
    {
    header: 'Priority',
    width:100,
    sortable:true,
    dataIndex: 'priority'
    },
    {
    header: 'Date Due',
    width:100,
    sortable: true,
    dataIndex: 'duedate'

    }
    ]
    );
    }
    return columnModel;
    }

    function buildGrid() {
    grid = new Ext.grid.Grid(
    'mygrid',
    {
    ds: ds,
    cm: getColumnModel(),
    autoSizeColumns: true
    }
    );
    grid.render();
    }

    function addSearchField(){
    search = new Ext.form.ComboBox({
    store: ds,
    displayField:'title',
    typeAhead: false,
    loadingText: 'Searching...',
    width: 570,
    pageSize:10,
    hideTrigger:true,
    applyTo: 'search'
    });
    }

    return {
    init : function() {
    setupDS();
    buildGrid();
    addSearchField();
    },

    getDataSource: function() {
    return ds;
    }
    }
    }();

    Ext.onReady(GridUI.init, GridUI, true);


  • oh, i forgot to add the html file:



















  • Please post your code in php or code tags for help :)







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Problem when try to create live search in gridPanel , Please add it free.