private static void Filter(ref VirtualDataTable aTable, string RowFilter, ref bool TableNeedsDispose, string aName) { RowFilter = RowFilter.Trim(); if (string.IsNullOrEmpty(RowFilter)) { if (aTable.TableName != aName) { VirtualDataTable nTable = aTable.FilterData(aName, null); if (aTable != null && TableNeedsDispose) { aTable.Dispose(); } aTable = nTable; TableNeedsDispose = true; } return; } int fPos = RowFilter.IndexOf(ReportTag.StrOpenParen); if (fPos > 2) { if (String.Equals(RowFilter.Substring(0, fPos).Trim(), ReportTag.ConfigTag(ConfigTagEnum.Distinct), StringComparison.InvariantCultureIgnoreCase)) { if (RowFilter[RowFilter.Length - 1] != ReportTag.StrCloseParen) { FlxMessages.ThrowException(FlxErr.ErrInvalidFilterParen, RowFilter); } VirtualDataTable bTable = aTable.GetDistinct(aName, GetColumnsForDistinct(aTable, RowFilter.Substring(fPos + 1, RowFilter.Length - fPos - 2))); if (aTable != null && TableNeedsDispose) { aTable.Dispose(); } aTable = bTable; TableNeedsDispose = true; return; } } VirtualDataTable cTable = aTable.FilterData(aName, RowFilter); if (aTable != null && TableNeedsDispose) { aTable.Dispose(); } aTable = cTable; TableNeedsDispose = true; }
/// <summary> /// This method will be called when a Split master wants to know how many records its detail has. For example, if the detail has 30 records /// and the split is at 10, the Split master will call this method to find out that it has to return 3 on its own record count. /// You need to filter the data here depending on the master detail relationships, but not on the splitLink. /// </summary> /// <remarks> /// You do not need to implement this method if you are not using Split relationships. /// </remarks> /// <param name="masterDetailLinks">List of all the master tables that are related to this one. /// If there are no parents on this VirtualDataTableState, this will be an empty array, not null. /// </param> /// <returns>The count of records for a specific position of the master datsets.</returns> public virtual int FilteredRowCount(TMasterDetailLink[] masterDetailLinks) { FlxMessages.ThrowException(FlxErr.ErrTableDoesNotSupportTag, FTableData.TableName, ReportTag.ConfigTag(ConfigTagEnum.Split)); return(-1); //just to compile. }
/// <summary> /// Override this method to return a new VirtualDataSet with unique values. /// Note that the returned dataset will not have all the columns this one has, only the ones defined on "filterFields" /// </summary> /// <remarks> /// You do not need to implement this method if you do not want to let users create "Distinct()" filters on the config sheet. /// </remarks> /// <param name="newDataName">How this new VirtualDataSet will be named. This is what the user wrote on the config sheet, /// when creating the distinct dataset. Note that as with all the VirtualDataSets, this name is meaningless except for error messages.</param> /// <param name="filterFields">Fields where to apply the "distinct" condition.</param> /// <returns>A new VirtualDataTable with the filtered data and the new name.</returns> public virtual VirtualDataTable GetDistinct(string newDataName, int[] filterFields) { FlxMessages.ThrowException(FlxErr.ErrTableDoesNotSupportTag, FTableName, ReportTag.ConfigTag(ConfigTagEnum.Distinct)); return(null); //just to compile. }