We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Formula like cells in GridGroupingControl

Hi, I am using GridGroupingControl.I want to implement Excel like formulas for few columns. Does GridGroupingControl support this..? I want grouping functionality as well. Also the formulas vary for each row depending on the column value. How can I do this..?can I get a sample code..? Thanks, Prathima

8 Replies

AD Administrator Syncfusion Team June 8, 2005 09:23 AM UTC

GridGroupingControl only supports Expression columns. See the grid user guide tutorial section on the GridGroupingControl Designer. It steps you through add an expression field. There, you can add exprssion similar to those that you can use in a DataColumn.Expression property. It allows you to reference other columns in the same record, but you cannot reference other records. The Excel-Like formula support (=A1 + 5 * B23) is only available in our GridControl.


PV Prathima Venkobachar June 8, 2005 10:54 AM UTC

Hi, Can you please give me asample code..? I don''t have tutorials.. Thx, Prathima


AD Administrator Syncfusion Team June 8, 2005 01:43 PM UTC

Here is a link to the online documentation. http://www.syncfusion.com/studio/ Here is some code. parentID is a column in the DataTable. this.gridGroupingControl1.TableDescriptor.ExpressionFields.Add("test"); this.gridGroupingControl1.TableDescriptor.ExpressionFields["test"].Expression = "2 * [parentID] + 86";


PV Prathima Venkobachar June 9, 2005 06:30 AM UTC

Thx,It works fine. I had created sample application ,It works fine in that. But for some reason, expression field is not visible in my application.The expression field is addded but doesn''t show up on the form.. I even tried to add the expression column to the visible colums.But still it is not display... Thx, Prathima


AD Administrator Syncfusion Team June 9, 2005 09:44 AM UTC

Here is a sample. All I did was to drop a GridGroupingControl on a form, add a datatable datasource, and use the two lines from above. http://www.syncfusion.com/Support/user/uploads/GGC_ExpressionField_1ef39a50.zip If you are working with the visiblecolumns collections, make sure use us eteh exact case everywhere when you refer to the column names. If you cannot spot the problem and can upload a sample project showing the problem, then we can look for it here.


PV Prathima Venkobachar June 9, 2005 10:00 AM UTC

Hi, Even I hv tried the same way in my sample code.That perfectly works fine. But when I tried to work with visible column collection this doesn''t work. What I observed is also any property I set to GridGroupingControl.TableModel or GridGroupingControl.TableDescriptor , this doesn''t work.If I comment out these lines if works perfectly fine. I have sent the peace of code,it is just looping through each values in the arraylist,if the value is visible adds it to the visible columns. After this I am setting the expression field. groupingGridControl.TableDescriptor.Columns.LoadDefault(); GridVisibleColumnDescriptorCollection visibleColumns = groupingGridControl.TableDescriptor.VisibleColumns; visibleColumns.Clear(); for(int i = 0; i < selectedCols.Selected.Count; i ++) { GridTableCellStyleInfo assetStyle; if (selectedCols.Selected[i].IsReadOnly) { assetStyle = new GridTableCellStyleInfo(readOnlyAssetStyle); } else { //editableAssetStyle.MaxLength = selectedCols.Selected[i].length; assetStyle = new GridTableCellStyleInfo(editableAssetStyle); } string displayName = selectedCols.Selected[i].DisplayName; GridColumnDescriptor colDescriptor1 = new GridColumnDescriptor( displayName , selectedCols.Selected[i].Key, displayName ,Convert.ToBoolean(selectedCols.Selected[i].IsReadOnly),Convert.ToInt32(selectedCols.Selected[i].DefColWidth)); colDescriptor1.Appearance.AnyRecordFieldCell = assetStyle; if (selectedCols.Selected[i].DbName.ToUpper() == DBColumns.Priority) { colDescriptor1.Appearance.AnyRecordFieldCell = cellStyle1; } if (selectedCols.Selected[i].DbName.ToUpper() == DBColumns.Registration) { colDescriptor1.Appearance.AnyRecordFieldCell = cellStyle2; } groupingGridControl.TableDescriptor.Columns[selectedCols.Selected[i].Key] = colDescriptor1; groupingGridControl.TableDescriptor.VisibleColumns.Add(colDescriptor1.Name); if (selectedCols.Selected[i].IsAlwaysHidden) { groupingGridControl.TableDescriptor.Columns[selectedCols.Selected[i].Key].Width = 0; } if (selectedCols.Selected[i].DbName.ToUpper() == DBColumns.AssetName) { SortColumnDescriptorCollection gridSortCols = groupingGridControl.TableDescriptor.SortedColumns; gridSortCols.Clear(); gridSortCols.Add(selectedCols.Selected[i].DbName); } } this.groupingGridControl.TableDescriptor.ExpressionFields.Add("test"); this.groupingGridControl.TableDescriptor.ExpressionFields["test"].Expression = "2 * [price] + 86"; Thx, Prathima


AD Administrator Syncfusion Team June 9, 2005 10:38 AM UTC

Try adding your expression field before you call COlumns.LoadDefault and also add it to your visible columns. GridTableDescriptor td = this.gridGroupingControl1.TableDescriptor; td.ExpressionFields.Add("test"); td.ExpressionFields["test"].Expression = "2 * [Col1] + [Col2]"; td.Columns.LoadDefault(); td.VisibleColumns.Clear(); td.VisibleColumns.Add("Col2"); //...add other columns to make them visible //add the expression col td.VisibleColumns.Add("test");


PV Prathima Venkobachar June 9, 2005 11:26 AM UTC

Hi, This works fine... Thanks a lot !!! Thx, Prathima

Loader.
Live Chat Icon For mobile
Up arrow icon