How to get better performance with DataGrid?


#1

I’m using version 2.0 of the grid, with the new API, from C# and Xamarin.iOS.

Bringing up a grid of very simple cells seems to take around one second (on an iPad mini).  At first I thought it was a performance problem with my data retrieval in PrepareCell.  But I’ve removed everything specific to my app and I still have approximately the same performance.

Here is the code for my DataSource:

public class zb_grid_datasource : SDataGridDataSource
{   
    public zb_grid_datasource()
    {   
    }   

    protected override void PrepareCellForDisplay (ShinobiDataGrid grid, SDataGridCell cell)
    {   
        int row = cell.Coordinate.Row.RowIndex;
        int col = cell.Coordinate.Column.DisplayIndex;

        SDataGridTextCell tc = cell as SDataGridTextCell;

        tc.TextField.Text = string.Format("{0}", row * col);
    }   

    protected override uint GetNumberOfRowsInSection(ShinobiDataGrid grid, int sectionIndex)
    {   
        return (uint) 40; 
    }   

    [Export ("conformsToProtocol:")]
    public override bool ConformsToProtocol (IntPtr protocol)
    {   
        return base.ConformsToProtocol(protocol);
    }   
}

And here is the code to create the grid and columns:

_grid = new ShinobiDataGrid(new RectangleF(0, 44, View.Bounds.Size.Width, View.Bounds.Size.Height-44));

_grid.DefaultRowHeight = 40; 
_grid.CanReorderRows = false;
_grid.LicenseKey = "(key)";
_grid.SelectionMode = SDataGridSelectionMode.None;
_grid.SingleTapEventMask = SDataGridEvent.None;
_grid.DoubleTapEventMask = SDataGridEvent.None;

foreach (string c in new string[] { "A", "B", "C", "D", "E", "F", "G", })
{   
    SDataGridColumn gridcol = new SDataGridColumn(c);
    gridcol.CanReorderViaLongPress = false;
    gridcol.CanResizeViaPinch = false;
    gridcol.Editable = false;
    gridcol.Width = 120;
    _grid.AddColumn(gridcol);
}   

_grid.DataSource = new zb_grid_datasource();

This is being shown on the detail side of a split view controller.  There are 6 columns visible and 16 rows visible.  A one-second delay seems like a very long time to create and show 96 cells.

Is there anything I can do to make this faster?


#2

Anyone have any thoughts on this?

This level of performance seems like a pretty big problem.


#3

Let me try asking this a different way:

Is the performance I’m seeing typical?  Or is it specific to the Xamarin.iOS binding?


#4

Hey Ericsink,

Sorry your post was missed – let’s see if we can help you resolve your issue. The marshalling / reflection that occurs between the managed C# and the native code does result in a performance impact – this is true of any code that uses Xamarin. However, with our tests on the ShinobiDataGrid this overhead we observed to be pretty small, not in the order of seconds.

Could we ask you to contact us via email to info@shinobicontrols.com, explaining the problem you are seeing, including a zip of the project demonstrating the above behaviour? Then we will get someone to look into the problem straight away .

Thanks,

Jan