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
335
XamDataGrid Filtering External with multiple layouts
posted

Hi

In your sample "Custom Filtering by External UI" you show the ability to filter using an external text box. However I have an issue with multiple Field Layouts.

I have the following code which creates a "Drill Down" grid that has two levels - a "Database" level and a "Case" level where each case has one database but each database has multiple cases.

I am using your code to implement my own external filters which works well for the the top level (database) but not for the second level.

I have modified the second  level code to use FieldLayouts[1] rather than FieldLayouts[0] but nothing happens when I perform the filter.

This is my search method which is called whenever an operand or criteria value is changed:

/// <summary>
/// Performs the search
/// </summary>
private void Search()
{
if (_databasesLoaded == false)
return;

var databaseLevelCollection = CasesDataGrid.FieldLayouts[0].RecordFilters;
databaseLevelCollection.Clear();

//database name
if (string.IsNullOrWhiteSpace(DatabaseNameFilter.Text) == false)
{
var operand = GetOperand(DatabaseNameOperand.SelectedItem.ToString());
var filter = new RecordFilter
{
FieldName = "DatabaseName"
};
filter.Conditions.Add(new ComparisonCondition(operand, DatabaseNameFilter.Text));
databaseLevelCollection.Add(filter);
}

//get and clear the data grid filter
var filterCollection = CasesDataGrid.FieldLayouts[1].RecordFilters;
filterCollection.Clear();

//case reference
if (string.IsNullOrWhiteSpace(CaseReferenceFilter.Text) == false)
{
var operand = GetOperand(CaseOperand.SelectedItem.ToString());
var filter = new RecordFilter
{
FieldName = "Reference"
};
filter.Conditions.Add(new ComparisonCondition(operand, CaseReferenceFilter.Text));
filterCollection.Add(filter);
}

//case description
if (string.IsNullOrWhiteSpace(CaseDescriptionFilter.Text) == false)
{
var operand = GetOperand(CaseDescriptionOperand.SelectedItem.ToString());
var filter = new RecordFilter
{
FieldName = "Description"
};
filter.Conditions.Add(new ComparisonCondition(operand, CaseDescriptionFilter.Text));
filterCollection.Add(filter);
}

//case status
if (CaseStatusFilter.Text != Strings.All)
{
var operand = GetOperand(CaseStatusOperand.SelectedItem.ToString());
var filter = new RecordFilter
{
FieldName = "CurrentStatus"
};
filter.Conditions.Add(new ComparisonCondition(operand, CaseStatusFilter.Text));
filterCollection.Add(filter);
}

//created by
if (string.IsNullOrWhiteSpace(CaseCreatedByFilter.Text) == false)
{
var operand = GetOperand(CaseCreatedByOperand.SelectedItem.ToString());
var filter = new RecordFilter
{
FieldName = "CreatedBy"
};
filter.Conditions.Add(new ComparisonCondition(operand, CaseCreatedByFilter.Text));
filterCollection.Add(filter);
}

//last modified by
if (string.IsNullOrWhiteSpace(CaseLastModifiedByFilter.Text) == false)
{
var operand = GetOperand(CaseLastModifiedByOperand.SelectedItem.ToString());
var filter = new RecordFilter
{
FieldName = "LastModfiedBy"
};
filter.Conditions.Add(new ComparisonCondition(operand, CaseLastModifiedByFilter.Text));
filterCollection.Add(filter);
}

//number of samples
if (CaseNumberOfSamplesFilter.Value != null && CaseNumberOfSamplesFilter.Value > 0)
{
var operand = GetOperand(CaseNumberOfSamplesOperand.SelectedItem.ToString());
var filter = new RecordFilter
{
FieldName = "NumberOfSamples"
};
filter.Conditions.Add(new ComparisonCondition(operand, CaseNumberOfSamplesFilter.Text));
filterCollection.Add(filter);
}
}

The code for the field declarations is:

<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowEdit="False"
AllowGroupBy="False"
AllowRecordFiltering="true"
CellClickAction="SelectRecord"
CollapseWhenEmpty="true"
ExpandableFieldRecordExpansionMode="ShowExpansionIndicatorIfSiblingsExist"
ExpandableFieldRecordHeaderDisplayMode="NeverDisplayHeader"
FilterLabelIconDropDownType="SingleSelect"
LabelClickAction="SortByOneFieldOnly"
SortComparisonType="CaseInsensitive" />
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings AllowAddNew="False"
AllowClipboardOperations="None"
AllowDelete="False"
AllowFieldMoving="No"
AllowRecordFixing="No"
AutoGenerateFields="False"
DataRecordSizingMode="Fixed"
ExpansionIndicatorDisplayMode="CheckOnDisplay"
FieldResizingArea="LabelsOnly"
FilterClearButtonLocation="None"
FilterRecordLocation="OnTopFixed"
FilterUIType="LabelIcons"
HeaderPrefixAreaDisplayMode="None"
RecordSelectorLocation="None"
ResizingMode="Immediate"
SelectionTypeField="None"
SelectionTypeRecord="Single" />
</igDP:XamDataGrid.FieldLayoutSettings>
<!-- The actual fields -->
<igDP:XamDataGrid.FieldLayouts>
<!-- Grim Database Level - These are the database columns -->
<igDP:FieldLayout Key="GRIMDatabase">
<igDP:FieldLayout.Fields>
<igDP:Field Name="DatabaseName" Label="{x:Static languages:Strings.DatabaseFile}" AllowRecordFiltering="True">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="300" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="NumberOfCases" AllowRecordFiltering="True"
HorizontalContentAlignment="Left"
Label="{x:Static languages:Strings.TotalNumberOfCases}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="200" />
</igDP:Field.Settings>
</igDP:Field>
<!-- This allows us to expand and drill down into cases -->
<igDP:Field Name="AvailableCases"
IsExpandable="True"
IsPrimary="True" AllowRecordFiltering="True"
IsSelected="True"
Label="AAA" />
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
<!-- Case Level - These are the case columns -->
<igDP:FieldLayout Key="AvailableCases"
ParentFieldLayoutKey="GRIMDatabase"
ParentFieldName="AvailableCases">
<igDP:FieldLayout.Fields>
<igDP:TemplateField Name="IsChecked"
AllowEdit="False"
AllowResize="False"
Label=" ">
<igDP:Field.Settings>
<igDP:FieldSettings Width="50" />
</igDP:Field.Settings>
<igDP:TemplateField.DisplayTemplate>
<DataTemplate>
<CheckBox HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding Path=Value, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type igDP:CellValuePresenter}}}"
Style="{StaticResource NormalCheckBox}" />
</DataTemplate>
</igDP:TemplateField.DisplayTemplate>
</igDP:TemplateField>
<igDP:Field Name="Reference" AllowRecordFiltering="True"
Label="{x:Static languages:Strings.ReferenceColumnName}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="200" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="Description" AllowRecordFiltering="True"
HorizontalContentAlignment="Left"
AllowEdit="False"
Label="{x:Static languages:Strings.DescriptionColumnName}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="120" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="CurrentStatus"
HorizontalContentAlignment="Left"
AllowEdit="False" AllowRecordFiltering="True"
Converter="{StaticResource CaseStatusTranslator}"
Label="{x:Static languages:Strings.CaseStatusColumnName}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="50" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="CreatedBy" AllowRecordFiltering="True"
HorizontalContentAlignment="Left"
AllowEdit="False"
Label="{x:Static languages:Strings.CreatedByColumnName}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="160" />
</igDP:Field.Settings>
</igDP:Field>
<igDP:TemplateField Name="CreatedDate" AllowRecordFiltering="True"
HorizontalContentAlignment="Left"
AllowEdit="False"
Label="{x:Static languages:Strings.CreatedDateColumnName}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="130" />
</igDP:Field.Settings>
<igDP:TemplateField.DisplayTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource DateKindConverter}}" />
</DataTemplate>
</igDP:TemplateField.DisplayTemplate>
</igDP:TemplateField>
<igDP:TemplateField Name="LastModifiedBy" AllowRecordFiltering="True"
HorizontalContentAlignment="Left"
AllowEdit="False"
Label="{x:Static languages:Strings.LastModifiedByColumnName}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="160" />
</igDP:Field.Settings>
<igDP:TemplateField.DisplayTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource OperatorDisplayConverter}}" />
</DataTemplate>
</igDP:TemplateField.DisplayTemplate>
</igDP:TemplateField>
<igDP:TemplateField Name="LastModifiedDate" AllowRecordFiltering="True"
HorizontalContentAlignment="Left"
AllowEdit="False"
Label="{x:Static languages:Strings.LastModifiedDateColumnName}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="170" />
</igDP:Field.Settings>
<igDP:TemplateField.DisplayTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource DateKindConverter}}" />
</DataTemplate>
</igDP:TemplateField.DisplayTemplate>
</igDP:TemplateField>
<igDP:Field Name="NumberOfSamples" AllowRecordFiltering="True"
HorizontalContentAlignment="Left"
AllowEdit="False"
Label="{x:Static languages:Strings.NumberOfSamplesInCase}">
<igDP:Field.Settings>
<igDP:FieldSettings CellMinWidth="180" />
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>