1. #1
    Ext User
    Join Date
    Dec 2008
    Location
    Iowa
    Posts
    4
    Vote Rating
    0
    pchandr is on a distinguished road

      0  

    Question grid.getView().focusRow(n) does not seems to work if grid was renderd using Ajax

    grid.getView().focusRow(n) does not seems to work if grid was renderd using Ajax


    Hi,

    I am trying to set the focus on a particular row in the grid, but it does not seem to work on a GridPanel, grid was rendered using data from Ajax call, ajax call get data in JSON format.

    Here;s the code i am using, can anybody help me on this, i love extjs

    function buildextmorttable(resptext,contentdiv) {

    var jsonResp = Ext.util.JSON.decode(resptext);

    var store= new Ext.data.JsonStore({
    root:'mortgagePrice'
    ,fields:[
    {name:'noteRate', type:'string'}
    ,{name:'points', type:'string'}
    ,{name:'price', type:'string'}
    ]
    ,data:jsonResp
    });

    var cm = new Ext.grid.ColumnModel([
    {header: "Note Rate", width: 60, dataIndex: 'noteRate', sortable: true},
    {header: "Points", width: 60, dataIndex: 'points', sortable: true},
    {header: "Price", width: 60, dataIndex: 'price', sortable: true}
    ]);


    // create the grid
    var grid = new Ext.grid.GridPanel({
    store: store,
    columns:[
    {header: "", width: 30, dataIndex: 'noteRate', sortable: false,renderer: showradio},
    {header: "Note Rate", width: 60, dataIndex: 'noteRate', sortable: true},
    {header: "Points", width: 60, dataIndex: 'points', sortable: true},
    {header: "Price", width: 60, dataIndex: 'price', sortable: true,align:'center'}
    ],
    renderTo:contentdiv,
    collapsible:true,
    collapsed:false,
    stripeRows: true,
    width:230,
    height:190,
    title:'Mortgage Pricing'
    });



    grid.getSelectionModel().selectLastRow(); //does not work

    grid.getView().focusRow(7); // does not work

    grid.getView().focusEl.focus(); //does not work

    var rec = grid.getSelectionModel().getSelected(); //does not work
    }


    function doJSON(responsetext,processingdiv,contentdiv) {
    try {
    document.getElementById(processingdiv).style.display = "none";
    document.getElementById(contentdiv).style.display = "block";
    document.getElementById(contentdiv).innerHTML = "";
    buildextmorttable(responsetext,contentdiv);
    } catch (err) {
    Ext.MessageBox.alert('ERROR', 'Could not decode ' + responsetext);
    }
    }

    function doJSONWithExt(processingdiv,contentdiv)
    {
    //params : { action : 'getDate'}
    var paramstr = '{ action : ' + '"getDate"' + '}';
    document.getElementById(processingdiv).style.display = "block";
    document.getElementById(contentdiv).style.display = "none";
    Ext.Ajax.request({
    url : '/ilc/JSONServlet',
    params : paramstr,
    method : 'POST',
    success: function (result, request) {
    doJSON(result.responseText,processingdiv,contentdiv);
    },
    failure:function ( result, request) {
    Ext.MessageBox.alert('Failed', 'Successfully posted form: '+result.date);
    }
    });
    }

  2. #2
    Sencha User carol.ext's Avatar
    Join Date
    Jun 2007
    Location
    Littleton, Colorado, USA
    Posts
    677
    Vote Rating
    20
    carol.ext will become famous soon enough carol.ext will become famous soon enough

      0  

    Default


    Please use code tags when you post code. See these sections of the getting help guide:

    Advanced mode - shows the buttons you can use for code tags

    How to post code properly

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,507
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    The new GridPanel defers rendering to allow more layout processing to occur

    http://extjs.com/deploy/dev/docs/?cl...deferRowRender

    Set it to false.

  4. #4
    Ext User
    Join Date
    Dec 2008
    Location
    Iowa
    Posts
    4
    Vote Rating
    0
    pchandr is on a distinguished road

      0  

    Smile Your solution works like a charm

    Your solution works like a charm


    Animal You are great , Stuff works like a charm

Thread Participants: 2