[CLOSED] How to get column index of a gridpanel using javascript.

  1. #1

    [CLOSED] How to get column index of a gridpanel using javascript.


    I have gridpanel with 2 columns. On clicking any of the rows I need to populate a different grid. Using the item click event of the Grid view I could achieve the functionality. Below is the code I have used. Now, I want the itemclick event to be fired only when i click on the first column. It should not fire for the second column. Though the below java script I could get only the rowindex. If I get column index then i can restrict it from being fired. How do I get the column index. Please help.

    Javascript function:
     var loadTier3 = function(record, item, index, e, eOpts ){            
                var tier2 = record.store.data.getAt(e).data.Tier2
    This is the Gridview where am calling the above funct:

                                <ext:GridView ID="GrdViewMetrics" runat="server" MarkDirty="false" StripeRows="false" TrackOver="false">
                                        <ItemClick Fn="loadTier3">
    Last edited by Daniil; May 05, 2015 at 3:31 PM. Reason: [CLOSED]
  2. #2
    Hi arjunrvasisht

    I would recommend using

    It returns the index of the cell clicked which corresponds to the index of the column.

    So if you want to check for the first column please use

    if (item.cellIndex == 0)
  3. #3
    Hi EnZo,

    There is no such property under item. item.cellIndex is undefined.!!
  4. #4
    Hi arjunrvasisht

    Apologies. I am using Ext 3.1, it must not be available in Ext 2.x.

    In this case, I would recommend using CellClick instead of ItemClick

    Please view below

                <ext:GridView ID="GrdViewMetrics" runat="server" MarkDirty="false" StripeRows="false" TrackOver="false">
                            <CellClick Fn="loadTier3" />
    And corresponding JavaScript

            var loadTier3 = function (panel, htmlTD, cellIndex, record, tr, rowIndex, e, eOpts) {
                if (cellIndex == 0)
                 // your code here
  5. #5
    Thanks EnZo. Its working great.!!
    I have few rows in a disabled state. Is there a way I will get to know if the row is disabled or not through this function. Because, if its disabled i will not fire the click event.
  6. #6
    Glad to know it's working.

    How exactly are the rows being disabled? Are they given a CSS class? Is there a certain attribute that could be checked through record.data?

Similar Threads

  1. [CLOSED] renderer column index is wrong after column lock & unlock
    By susanz in forum 3.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 16, 2015, 5:13 PM
  2. [CLOSED] Remove Grid Column by column index.
    By pawangyanwali in forum 2.x Legacy Premium Help
    Replies: 17
    Last Post: Apr 22, 2014, 6:27 AM
  3. Replies: 2
    Last Post: Dec 11, 2013, 11:36 AM
  4. Replies: 0
    Last Post: Sep 27, 2012, 6:10 PM
  5. Replies: 3
    Last Post: Apr 08, 2010, 7:16 AM

Posting Permissions