Hello,
I have a scenario where I would like to create columns dynamically and have filters on that grid. So far, when I set the AllowFilteringByColumn to true and create the column dynamically at the OnNeedDataSource event. I receive an error when I try to filter "Expression Expected".
If I take that same column and declare it aspx page, I can filter no problem.
<telerik:RadGrid ID="rgPortfolio" runat="server"
AllowFilteringByColumn="true" MasterTableView-AllowPaging="true" PagerStyle-AlwaysVisible="true"
AllowSorting="true" AllowPaging="true" AutoGenerateColumns="false"
OnNeedDataSource="rgPortfolio_NeedDataSource"
OnColumnCreated="rgPortfolio_ColumnCreated">
<MasterTableView AllowFilteringByColumn="true" DataKeyNames="Id">
<Columns>
<%--<telerik:GridBoundColumn UniqueName="Cusip" DataField="Cusip"></telerik:GridBoundColumn>--%>
</Columns>
</MasterTableView>
</telerik:RadGrid>
private void BuildGridColumns()
{
rgPortfolio.Columns.Clear();
var col = new GridBoundColumn();
col.UniqueName = "cusip";
col.HeaderText = "cusip";
col.DataField = "cusip";
rgPortfolio.MasterTableView.Columns.Add(col);
}
protected void rgPortfolio_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
BuildGridColumns();
rgPortfolio.DataSource = Reporting.Investor.GetActivePortfolioItems();
}