This is a migrated thread and some comments may be shown as answers.

Filter Template with RadComboBox

1 Answer 324 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rodney
Top achievements
Rank 2
Rodney asked on 01 Jun 2017, 05:04 PM

I've been trying to get the Filter Template on the grid to work with a RadComboBox, but have not been successful. I'm binding to a dataset which is a little different than the example at Filter Template Example. The dropdown seems to load correctly the first time, but then when I make a selection it fails. I'm guessing it's in the client code because it never gets back to the .

I'm getting the error:

Selection out of range
Parameter name: value

Below is my code:

<telerik:RadGrid
    ID="rgAudits"
    runat="server"
    OnPreRender="rgAudits_PreRender"
    AllowPaging="True"
    AllowSorting="True"
    AutoGenerateColumns="False"
    CellSpacing="0"
    ClientSettings-AllowColumnsReorder="false" ClientSettings-Resizing-AllowColumnResize="false" ClientSettings-Scrolling-UseStaticHeaders="true"
    EnableLinqExpressions="False"
    ExportSettings-ExportOnlyData="false" ExportSettings-IgnorePaging="true" ExportSettings-OpenInNewWindow="true"
    ExportSettings-HideStructureColumns="true" ExportSettings-FileName="Audit"
    GridLines="None"
    GroupingSettings-CaseSensitive="false" MasterTableView-AllowMultiColumnSorting="false" MasterTableView-AllowNaturalSort="false"
    AllowFilteringByColumn="true" MasterTableView-CommandItemDisplay="Top"
    MasterTableView-CommandItemSettings-ShowAddNewRecordButton="false"
    MasterTableView-CommandItemSettings-ShowRefreshButton="false"
    MasterTableView-CommandItemSettings-ShowExportToCsvButton="false"
    MasterTableView-CommandItemSettings-ShowExportToExcelButton="true" ExportSettings-Excel-Format="Xlsx"
    MasterTableView-CommandItemSettings-ShowExportToPdfButton="true" ExportSettings-Pdf-AllowCopy="true" ExportSettings-Pdf-AllowPrinting="true"
    ExportSettings-Pdf-AllowModify="true"
    MasterTableView-CommandItemSettings-ShowExportToWordButton="true" ExportSettings-Word-Format="Docx"
    MasterTableView-PagerStyle-PagerTextFormat="{4} Page {0} of {1}, rows {2} to {3} of {5}"
    MasterTableView-PagerStyle-Position="TopAndBottom" MasterTableView-PagerStyle-PageButtonCount="10" MasterTableView-PagerStyle-EnableAllOptionInPagerComboBox="false"
    PagerStyle-PageSizes="10,25,50,100" PageSize="25" PagerStyle-AlwaysVisible="true"
    MasterTableView-TableLayout="Fixed">
    <GroupingSettings CaseSensitive="false" />
    <MasterTableView>
        <NoRecordsTemplate>
            <div>
                There are no records to display select a system from the drop down list.
            </div>
        </NoRecordsTemplate>
        <CommandItemSettings ShowExportToPdfButton="true" ShowExportToExcelButton="true" ShowAddNewRecordButton="false"
            ShowRefreshButton="false" />
        <SortExpressions>
            <telerik:GridSortExpression FieldName="CREATEDON" SortOrder="Descending" />
        </SortExpressions>
        <Columns>
            <telerik:GridBoundColumn UniqueName="AUDITID" DataField="AuditId" HeaderText="Audit ID" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
                ShowFilterIcon="false" FilterControlWidth="75px" ItemStyle-HorizontalAlign="Left"
                DataType="System.Int32" SortExpression="AUDITID">
                <HeaderStyle Width="110px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="FULLNAME" DataField="FullName" HeaderText="Created By" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                ShowFilterIcon="false" DataType="System.String" SortExpression="FULLNAME" ItemStyle-HorizontalAlign="Left">
                <HeaderStyle Width="160px" />
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn UniqueName="CREATEDON" DataField="CreatedOn" HeaderText="Created On" AutoPostBackOnFilter="true"
                PickerType="DatePicker"
                DataFormatString="{0:dd MMM yyyy hh:mm:ss}" HtmlEncode="false" CurrentFilterFunction="GreaterThanOrEqualTo" ShowFilterIcon="false"
                ItemStyle-HorizontalAlign="Left">
                <HeaderStyle Width="170px" />
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn UniqueName="AUDITTYPEDESCRIPTION" DataField="AuditTypeDescription" HeaderText="Type" AutoPostBackOnFilter="true"
                ShowFilterIcon="false" DataType="System.String" ItemStyle-HorizontalAlign="Left"
                CurrentFilterFunction="Contains" SortExpression="AUDITTYPEDESCRIPTION">
                <HeaderStyle Width="130px" />
                <FilterTemplate>
                    <telerik:RadComboBox RenderMode="Lightweight" ID="rcbAuditTypes" Skin="Default" DropDownAutoWidth="Enabled"
                        Width="128px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("AUDITTYPEDESCRIPTION").CurrentFilterValue %>'
                        runat="server" OnClientSelectedIndexChanged="AuditTypeIndexChanged">
                        <Items>
                            <telerik:RadComboBoxItem Text="All" />
                        </Items>
                    </telerik:RadComboBox>
                    <telerik:RadScriptBlock ID="rsbAuditType" runat="server">
                        <script type="text/javascript">
                            function AuditTypeIndexChanged(sender, args) {
                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                tableView.filter("AUDITTYPEDESCRIPTION", args.get_item().get_value(), "EqualTo");
                            }
                        </script>
                    </telerik:RadScriptBlock>
                </FilterTemplate>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn UniqueName="AUDITDESCRIPTION" DataField="AuditDescription" HeaderText="Description" AutoPostBackOnFilter="true"
                ShowFilterIcon="false" DataType="System.String" ItemStyle-HorizontalAlign="Left"
                CurrentFilterFunction="Contains" AllowSorting="false" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

 

private void refreshCombos()
{
    AdminServiceClient adminProxy = new AdminServiceClient();
    DataSet ds = adminProxy.GetUniqueAuditTypeCode(rgAudits.MasterTableView.FilterExpression.ToString());
    RadComboBox rcb = new RadComboBox();
    foreach (GridFilteringItem  item in rgAudits.MasterTableView.GetItems(GridItemType.FilteringItem))
    {
        rcb = (RadComboBox)item.FindControl("rcbAuditTypes");
    }
    rcb.DataTextField = "AuditDescription";
    rcb.DataValueField = "AuditTypeCode";
    rcb.DataSource = ds;
    rcb.DataBind();
    //rgAudits.MasterTableView.Rebind();
}

 

Note, in the example you have the rebind that I've commented out above. When I do this, my ComboBox comes out empty. If I leave it out, then I get the values in the Combo Box. 

I'm having a secondary problem with the ComboBox itself. Sometimes, the text in the  is huge, other times it's the right size. I have no idea what's causing this.

Thanks
Rodney

 

 

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 06 Jun 2017, 06:01 AM
Hello Rodney,

I've already replied in your ticket with ID: 1112447. I suggest that we continue our conversation on the mentioned thread.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Rodney
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Share this question
or