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

  1. #1

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

    Hello,

    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
                Ext.net.DirectMethods.check(tier2);
            }
    This is the Gridview where am calling the above funct:

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

    I would recommend using

    item.cellIndex
    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">
                        <Listeners>
                            <CellClick Fn="loadTier3" />
                        </Listeners>
                </ext:GridView>
    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