1. #1
    Touch Premium Member
    Join Date
    Sep 2010
    Location
    Chicago, IL
    Posts
    40
    Vote Rating
    1
    scgrif32 is on a distinguished road

      0  

    Question Ext Js 4 equivalent to getColumnModel()?

    Ext Js 4 equivalent to getColumnModel()?


    Hello again,

    I've ran into a slight bump in the road while attempting to get the column model for the cell that was clicked in the grid panel. Seems "getColumnModel()" is no longer a method for the grid panel.

    In my Ext Js 3 application I was able to use a listener on the grid for the "cellclick" event that allowed me to act upon the cell in the column that was clicked. I have a hidden column which contains the name of the file I want to download and I created an iframe that would be used to download the file asynchronously.

    Code snippet below:
    Code:
    listeners: {
        cellclick: function(grid,rowIndex,colIndex,e) {
            if (colIndex == 3) {
                var rec = grid.getStore().getAt(rowIndex);
                var fieldname = grid.getColumnModel().getDataIndex(colIndex + 1);
                var filename = rec.get(fieldname);
    
                if (!filename) return;
                var download_iframe = Ext.getCmp("report-download");
                if (!download_iframe) {
                         download_iframe = document.createElement('iframe');
                         download_iframe.id = 'report-download';
                         download_iframe.style.display = 'none';
                         download_iframe.height = '100';
                         download_iframe.width = '600';
                         document.body.appendChild(download_iframe);
                         download_iframe.src = SC.addToken(_const.BASE_PATH + '/download_report.php?FileName=' + escape(filename));
                } else {
                         download_iframe.src = SC.addToken(_const.BASE_PATH + '/download_report.php?FileName=' + escape(filename));
                }
                e.stopEvent();
            }
        }
    }
    Is there an equivalent in Ext Js 4? If not, can anyone help me figure out how to go about doing the same thing getColumnModel() use to do in Ext Js 3?

    Any help would be much appreciated.

    Thank you in advance,

    Shawn

  2. #2
    Sencha - Sales Team daniel.gallo's Avatar
    Join Date
    Apr 2009
    Location
    Bath, UK
    Posts
    50
    Vote Rating
    9
    daniel.gallo will become famous soon enough

      0  

    Default


    Hi Shawn,

    Try referencing the "grid.columns" property instead - this is an array of columns in the grid, so you should be able to pass in your column index to get a reference to the particular column. For more info, please see the following: http://docs.sencha.com/ext-js/4-0/#!...le-cfg-columns

    I hope that helps.

    Thanks

    Dan

  3. #3
    Touch Premium Member
    Join Date
    Sep 2010
    Location
    Chicago, IL
    Posts
    40
    Vote Rating
    1
    scgrif32 is on a distinguished road

      0  

    Default


    Daniel,

    Thank you for your response. Ironically, I was able to find a MUCH easier solution to get at the data I needed from the grid but I still have the issue of getting the "cell" that the "itemclick" event took place in.

    Despite using a checkbox selection model on my grid I am able to use the "itemclick" event which contains the record for the row that was clicked (whether cell or checkbox). The record coincidentally has the data for the entire grid row so there is no need to find the "rowIndex" or "colIndex" to get the "dataIndex" for the field (cell) I was searching for.

    However, I am still in need of figuring out which cell was clicked so I can determine if the cell that was clicked happened to the be cell that contained the <a href>. Any ideas how to do this in Ext Js 4?

    Thank you again,

    Shawn

Thread Participants: 1

Tags for this Thread