When I have both a numerically typed column and a text column in a grid, and allow filtering on both, the text options don't display properly if I click on the numeric column's options first.
In that scenario, I only show the "NoFilter" option on the text column, which is the only one that's common between the two types which I display. (I am using client-side javascript to not display some of the options based on unique name).
I don't see this problem on the numeric column if I click the text options first. Also, if I click the text options a second time after seeing the numeric options, then the right set of options (those which I keep) show up.
Note that I don't actually filter to see this problem. It's just clicking on the button to see the numeric options, then clicking on the text options. It does seem to be consistent and reproducible in IE 7 and Firefox, 32-bit Vista.
Also note that the order of my client-side script (copied below) doesn't seem to be important. I initially had the "numeric" area below the "text", and switched them, thinking I might see the opposite effect. No, it's always numeric filter options, then text which causes the problem.
Finally, the "Weight" column is decimal(32,8) in our database, but I think this problem manifests with any numeric type.
Here's an example grid from my application:
<telerik:RadGrid ID="grdStrategicCriterionSearchResults" runat="server"
EnableViewState="True"
OnNeedDataSource="grdStrategicCriterionSearchResults_NeedDataSource"
onSelectedIndexChanged="grdStrategicCriterionSearchResults_SelectedIndexChanged"
Visible="true">
<ClientSettings EnablePostBackOnRowClick="true">
<ClientEvents OnFilterMenuShowing="FilterMenuShowing" />
</ClientSettings>
<MasterTableView DataKeyNames="StrategicCriterionID"
RetrieveAllDataFields="False" EditMode="InPlace">
<NoRecordsTemplate>
No strategic criteria were found.
</NoRecordsTemplate>
<Columns>
<telerik:GridBoundColumn DataField="Name" HeaderText="Name"
UniqueName="colName" />
<telerik:GridBoundColumn DataField="Description"
HeaderText="Description" UniqueName="colDescription" />
<telerik:GridBoundColumn DataField="Weight" HeaderText="Weight"
UniqueName="colWeight" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
And the javascript for client-side filter display (this is in my Master page, so all the other unique names are columns in other grids in the application). I've left in some alerts I was using to debug.
function FilterMenuShowing(sender, eventArgs)
{
var menu = eventArgs.get_menu();
var items = menu._itemData;
var i = 0;
// Customize filter options.
// boolean
if (eventArgs.get_column().get_uniqueName() == "colSoftBenefit" ||
eventArgs.get_column().get_uniqueName() == "colEnabled" ||
eventArgs.get_column().get_uniqueName() == "colShared" ||
eventArgs.get_column().get_uniqueName() == "colSuper")
{
alert("in boolean area");
while (i < items.length)
{
var item = menu._findItemByValue(items[i].value);
if (item != null)
{
if (items[i].value != "EqualTo" &&
items[i].value != "NotEqualTo" &&
items[i].value != "NoFilter")
{
item._element.style.display = "none";
} else {
item._element.style.display = '';
}
}
i++;
}
}
//numeric/date
if (eventArgs.get_column().get_uniqueName() == "colStartYear" ||
eventArgs.get_column().get_uniqueName() == "colWeight" ||
eventArgs.get_column().get_uniqueName() == "colICCDiscountRate" ||
eventArgs.get_column().get_uniqueName() == "colTaxRate" ||
eventArgs.get_column().get_uniqueName() == "colDate" ||
eventArgs.get_column().get_uniqueName() == "colLevel" ||
eventArgs.get_column().get_uniqueName() == "colFiscalYear")
{
alert("in numeric area");
while (i < items.length)
{
var item = menu._findItemByValue(items[i].value);
if (item != null)
{
if (items[i].value != "GreaterThan" &&
items[i].value != "LessThan" &&
items[i].value != "NoFilter" &&
items[i].value != "EqualTo")
{
item._element.style.display="none";
} else {
item._element.style.display='';
}
i++;
}
}
}
// text-type filters
if (eventArgs.get_column().get_uniqueName() == "colName" ||
eventArgs.get_column().get_uniqueName() == "colText" ||
eventArgs.get_column().get_uniqueName() == "colPortfolioName" ||
eventArgs.get_column().get_uniqueName() == "colTemplateName" ||
eventArgs.get_column().get_uniqueName() == "colStrategicCriteria" ||
eventArgs.get_column().get_uniqueName() == "colDescriptor" ||
eventArgs.get_column().get_uniqueName() == "colDescriptorType" ||
eventArgs.get_column().get_uniqueName() == "colExp" ||
eventArgs.get_column().get_uniqueName() == "colUsername" ||
eventArgs.get_column().get_uniqueName() == "colProjectName" ||
eventArgs.get_column().get_uniqueName() == "colAction" ||
eventArgs.get_column().get_uniqueName() == "colSource" ||
eventArgs.get_column().get_uniqueName() == "colCategory" ||
eventArgs.get_column().get_uniqueName() == "colMessage" ||
eventArgs.get_column().get_uniqueName() == "colDescription" ||
eventArgs.get_column().get_uniqueName() == "colPrefixAndSeed" ||
eventArgs.get_column().get_uniqueName() == "colProjectMode" ||
eventArgs.get_column().get_uniqueName() == "colSuperDescriptor" ||
eventArgs.get_column().get_uniqueName() == "colInterval" ||
eventArgs.get_column().get_uniqueName() == "colUnitType" ||
eventArgs.get_column().get_uniqueName() == "colFirstName" ||
eventArgs.get_column().get_uniqueName() == "colLastName" ||
eventArgs.get_column().get_uniqueName() == "colEmail")
{
while (i < items.length)
{
var item = menu._findItemByValue(items[i].value);
if (item != null)
{
if (items[i].value != "Contains" &&
items[i].value != "EndsWith" &&
items[i].value != "StartsWith" &&
items[i].value != "NoFilter")
{
alert(
" setting filter option " + items[i].value + " off");
item._element.style.display="none";
} else {
item._element.style.display='';
alert(" setting filter option " + items[i].value + " on");
}
i++;
}
}
}
}
</script>