Flexgrid Events in Xamarin.iOS

Posted by: canderson on 8 August 2017, 2:05 am EST

    • Post Options:
    • Link

    Posted 8 August 2017, 2:05 am EST

    [xuni_archive]I am looking at replacing a grid control I am currently using in my Xamarin.iOS project with the Xuni Flexgrid. I’ve played around with some of the examples and have tried placing a grid in my project to display some data. I have a few questions about how touch events are managed and if they can be customized. I am using version 2.3.20171.185.

    I was looking to see if there was a way to make a cell editable just by tapping on it (instead of double tapping.) Even if there isn’t a built-in way to change this, I figured there must be some way to handle it. While I was looking at this, I was trying to see about using the tap, double-tap and long touch events. CellTapped and CellDoubleTapped appear to be mapped to objects, while CellLongPressed is an event handler. What is the proper way to handle these events? Other than basic text entry cells, most of my cells will use a custom editor.

    Also, if I have a grid that is sometimes editable and sometimes now, is there a way to globally disable the editors? I tried setting grid.IsEnabled to false, but this also appears to disable scrolling in the table.[/xuni_archive]

  • Posted 8 August 2017, 2:05 am EST

    [xuni_archive]Hello

    Here’s a breakdown of what each event would look like on Xamarin.iOS. You would need to add your event handlers in ViewDidLoad:

    
                this.flexGrid.CellTapped += grid_CellTapped;
                this.flexGrid.CellDoubleTapped += grid_CellDoubleTapped;
                this.flexGrid.CellLongPressed += FlexGrid_CellLongPressed;
    

    And then the actual methods you would add would look like this:

    
    //Enters edit mode on a single click
      private bool grid_CellTapped(FlexGrid sender, GridPanel panel, GridCellRange range)
            {
                bool result = false;
                sender.StartEditing(true, range.Row, range.Col);
                return result;
            }
    //Cancels the event and editing on a double click
            private bool grid_CellDoubleTapped(FlexGrid sender, GridPanel panel, GridCellRange range)
            {
                bool result = true;
    
                return result;
            }
    //Also enters edit on a long press
            private void FlexGrid_CellLongPressed(object sender, CellLongPressedEventArgs e)
            {
                ((FlexGrid)sender).StartEditing(true, e.Range.Row, e.Range.Col);
            }
    

    As far as disabling edits, you can set the FlexGrid to read only mode:

    
    this.flexGrid.isReadOnly = true;
    

    [/xuni_archive]

  • Posted 8 August 2017, 2:05 am EST

    [xuni_archive]Thanks, that definitely helps get me going in the right direction. It does behave in a very odd manner if you tap on one cell and then tap on another one, though.

    For instance, if you tap on cell at [0,0], that cell is correctly selected.

    But, if you don’t hit Done to dismiss the keyboard and then tap on [2,1], grid_CellTapped does get called again, but the range still points to [0,0].

    If you then tap [2,0], it selects [1,0].

    Similarly, if you start at [1,0] and then tap [4,0], [2,0] is selected.

    and if you start at [3,3] and then tap [4,1], [0,1] is selected.

    It seems to be consistent with the choices, but still an odd behavior. Is there something I need to set to allow me to select the next cell correctly?[/xuni_archive]

  • Posted 9 July 2021, 4:43 am EST

    Hello everyone!!!.. I wonder if there is a List or manual containing every event triggered by the FlexGrid

    Thanks!!!

  • Posted 11 July 2021, 11:17 pm EST

    Hello

    Please refer to the below documentation link, which refers to the events triggered by the FlexGird

    https://www.grapecity.com/componentone/docs/xamarin/online-forms/C1.Xamarin.Forms.Grid~C1.Xamarin.Forms.Grid.FlexGrid_events.html

    Please let me know if you need any other help.

    Thanks

  • Posted 4 August 2021, 4:48 am EST

    Thanks!!! it worked excellent!!!

Need extra support?

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

Learn More

Forum Channels