Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
Image in cell
posted

Hi,

I'm using infragistic's grid for add-in app in AutoCAD. Usually the amount of data is very large (20.000-100.000 or even more). By default I use load on demand technique, which is very fast and works just great, but ... I had to disable almoust all the features of grid (group by, filter sort ...), so I made the other option, whitch preloads all data in datatable. With code above I add image columns for zoom, edit, attach ... and found out that this is the problem. Even if I load all records (in advanced mode), when user uses filter or group by or and other functionallity that needs all rows, grid becomes very slow and imposible to use. If I comment all the code in InitializeRow event, that doesn't happen. Should I draw images in cell on any other event, or could I get any property of e.Row object which would tell me if row is actually visible? I tried with property e.Row.VisibleIndex (in InitializeRow event), but I allways get value -1.

On web I am using ExtJs's Grid, which has great feature called ActionRow. That enables me to add some actions (string - action key, image - action image, string - function name), and grid  automaticly adds column with images. If user clicks the image, function fires.

If Infragistics Grid would have feature like that, that would be amazing.

I would like to thank for any answer in advance!

 

CODE:

 

//I call this void on InitializeLayout event of grid.

public static void AddImgColumn(ColumnsCollection columns, string colKey, bool addToEnd)

{

            if (!columns.Exists(colKey))

            {

                UltraGridColumn col;

                if (addToEnd)

                    col = columns.Add(colKey);

                else

                    col = columns.Insert(0, colKey);

                col.Width = 20;

                col.AllowRowFiltering = DefaultableBoolean.False;

                col.AllowRowSummaries = AllowRowSummaries.False;

                col.AllowGroupBy = DefaultableBoolean.False;

                col.ExcludeFromColumnChooser = ExcludeFromColumnChooser.True;

                col.CellActivation = Activation.NoEdit;

                col.CellClickAction = CellClickAction.CellSelect;

                col.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Image;

                col.Header.Caption = "";

                col.Header.Fixed = true;

            }

}

//This void I call on InitializeRow event of grid

 

 

public static void SetCellImage(UltraGridRow row, string columnKey, Bitmap bmp, string tooltip)

{

            if (row.Cells.Exists(columnKey))

            {

                row.Cells[columnKey].Appearance.ImageBackground = bmp;

                row.Cells[columnKey].Appearance.Cursor = System.Windows.Forms.Cursors.Hand;

                if (tooltip != null)

                    row.Cells[columnKey].ToolTipText = tooltip;

            }

}

private void ugMain_InitializeRow(object sender, InitializeRowEventArgs e)

{

            UltraGridUtils.SetCellImage(e.Row, Globals.ZoomColumnKey, Kaliopa.AutoCAD.FDO.DataGrid.Properties.Resources.zoomfeature, "Prikaži v risbi");

            UltraGridUtils.SetCellImage(e.Row, Globals.EditRowColumnKey, Kaliopa.AutoCAD.FDO.DataGrid.Properties.Resources.ROW_EDIT, "Uredi podatke");

            UltraGridUtils.SetCellImage(e.Row, Globals.RelationsColumnKey, Properties.Resources.table_relationship, "Prikaži podatke povezanih tabel");

            if (e.Row.Cells.Exists(Globals.AttachmentsColumnKey))

            {

                if (e.Row.GetCellValue(Globals.colPriponke) != DBNull.Value)

                    e.Row.Cells[Globals.AttachmentsColumnKey].Appearance.ImageBackground = Kaliopa.AutoCAD.FDO.DataGrid.Properties.Resources.attachments_ADDED;

                else

                    e.Row.Cells[Globals.AttachmentsColumnKey].Appearance.ImageBackground = Kaliopa.AutoCAD.FDO.DataGrid.Properties.Resources.attachments;

                e.Row.Cells[Globals.AttachmentsColumnKey].Appearance.Cursor = Cursors.Hand;

            }

}

 

 

 

 

// I call this void in InitializeLayout event, based on the type of grid user selects

#region DisplaySettings

public static void SetLoadOnDemandSettings(UltraGrid grid)

        {

            grid.DisplayLayout.LoadStyle = LoadStyle.LoadOnDemand;           

            grid.DisplayLayout.ScrollStyle = ScrollStyle.Immediate;

            grid.DisplayLayout.ScrollBounds = ScrollBounds.ScrollToFill;

            grid.DisplayLayout.ViewStyleBand = ViewStyleBand.Vertical;

            grid.DisplayLayout.ViewStyle = ViewStyle.SingleBand;

            grid.DisplayLayout.Override.AllowGroupBy = DefaultableBoolean.False;

            grid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;

            grid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Select;

}

public static void SetAdvancedSettings(UltraGrid grid)

{

            grid.DisplayLayout.LoadStyle = LoadStyle.LoadOnDemand;            

            grid.DisplayLayout.ScrollStyle = ScrollStyle.Immediate;

            grid.DisplayLayout.ScrollBounds = ScrollBounds.ScrollToFill;

            grid.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;

            grid.DisplayLayout.ViewStyle = ViewStyle.SingleBand;

            grid.DisplayLayout.Override.AllowGroupBy = DefaultableBoolean.True;

            grid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True;

            grid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.SortMulti;          

}

#endregion

Parents Reply Children