how to add handler to cellTapped in flex Grid?

Posted by: nilekapawan on 8 August 2017, 10:40 am EST

  • Posted 8 August 2017, 10:40 am EST

    i have created grid using xuni flexGrid. But i can't add handler to cell tapped.i want to get know how to add handler to cell.there are two column in my grid. I want to add handlers to cells in first column and second column separately.please help me..
  • Replied 8 August 2017, 10:40 am EST

    Hello

    You don't add handlers individually per column, but rather one will handle the whole grid. The event returns a cellrange which you can use to determine which cell (or range of cells) has been selected. In your case I'll assume this is single cell selection, so you'll need to add the handler into your OnCreate method:


    mGrid.getCellTapped().addHandler(mGridCellTappedListener, mGrid);



    And then you'll need to create a separate event handler where the EventArgs that are returned are the cell range, and create conditional logic to do separate things based on the column:


    private IEventHandler mGridCellTappedListener = new IEventHandler()
    {
    @Override
    public void call(Object arg0, Object arg1)
    {
    GridCellRangeEventArgs args = (GridCellRangeEventArgs) arg1;

    if (args.range.isValid())
    {
    if (args.range.col == 0)
    {
    //do something
    }
    else if (args.range.col == 1)
    {
    //do something else
    }
    }
    }
    };
  • Replied 8 August 2017, 10:40 am EST

    You solved my problem.Thank you very much...
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels