grid header filter cobx datasource codebehind

10 posts, 0 answers
  1. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 04 Jan 2010 Link to this post

    hi,

    i have a grid and want to choose the filter in the column with a Combobox in a Filter Template. But i dont know how i set the items in that combobox at pageload in the codebehind..

    I want to make a visible image and maybe invisible text for the value. The image urls are in my database which i access with my datalayer. (all code behind)

    Any ideas?

    thx mario
  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 04 Jan 2010 Link to this post

    Hi Mario,

    One way of achieving this is by using a FilterTemplate and bind the RadComboBox to a DataSource returning empty string for the Text field. 

    Please see this similar example.

    Greetings,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 21 Jan 2010 Link to this post

    fine thx,

    but heres another rock i encounterd in my way:

    i have following template column

    <telerik:GridTemplateColumn HeaderText="inUse" UniqueName="inUse" ItemStyle-Width="36px"
           <ItemTemplate> 
                   <telerik:RadToolTip ID="tipInUse" runat="server"  
                             TargetControlID="imgInUse" AutoCloseDelay="60000" > 
                   </telerik:RadToolTip> 
                   <asp:Image runat="server" ID="imgInUse" Width="20px" Height="20px"/> 
                   <asp:TextBox ID="txbInEditMode" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"is_ineditmode").ToString() %>' /> 
                   <asp:TextBox ID="txbIsCheckedout" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"is_checkedout").ToString() %>' /> 
            </ItemTemplate> 
     </telerik:GridTemplateColumn> 

    in code behind i read out the rextboxes to set the image visible or not if one of the two textboxes got "true" set as text.

    how am i able to add filtertemplate with a RadComboBox which uses the image.Visible status for the filtering?

    thx. Mario

  5. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 27 Jan 2010 Link to this post

    Hi Mario,

    In your case there will be an Image for each Grid Item. It is unclear which of the Images the RadComboBox will take into account when filtering.

    Are the is_ineditmode and is_checkedout flags unique for each Item or they the same and only suggest the current Mode of the Grid?

    Kind regards,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 27 Jan 2010 Link to this post

    hi simon,

    sry heres more information:

    there are two ways of which my object (of the datarow) gets the "InUse" image visible set to true. if its currently being edited or checked out. i set so i set the visible status in the RadGrid_ItemDataBound event.

    I already know that i can access the object via DataItem:

    GridDataItem item = e.Item as GridDataItem;
    Document doc = item.DataItem as Document;

    and i dont need the 2 textboxes to hold the status information of the obejct. (Thats just a old code artifact i have to refactor)

    is_ineditmode and is_checkedout is for deciding wether showing the ImageInUse of one object or not. the dataitem object holds these information.

    besides the filter problem: i dont know how to set its visible status in the asp.net code so i do it in the codebehind behind event.

    cheers mario
  7. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 02 Feb 2010 Link to this post

    Hi Mario,

    Thank you for clarifying.

    So you want to find the FilterCombo and set its Visible property. Is this correct? If yes, which value will indicate that, having in mind that the Filter Grid Item does not have a DataItem associated with it?

    Sincerely yours,
    Simon
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  8. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 02 Feb 2010 Link to this post

    hi,

    i know how to find/access my FilterCombobox in the headerfilter item.

    i dont know how to connect that filtercombobox with the columns image. That image gets it visible status in the codebehind itembound method, which checks the 2 textboxes if the image should be visible or not.

    PS.:

    By the way i changed that from "visible"/"not visible" to different image sources. one is a transparent pixel and the other is the normal lock showing that the datarow is "inUse". But its still the same problem.

    Is it the situation, that there is no way to filter something that isnt automatically bound from the DataItem? (And i cant do that, because i have to check 2 fields (of the dataItem) for one column(of the grid) deciding wether to show the picture or just showing the transparent pixel)

    cheers Mario
  9. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 09 Feb 2010 Link to this post

    Hi Mario,

    Can you please describe in more detail where is this Image located and how exactly do you want to use it with the filter RadComboBox? ("i dont know how to connect that filtercombobox with the columns image.")

    In any case, I would like to ask you to summarize your base configuration and the functionality you want to achieve starting from it. Only when I have a clear description of your goal I will be able to provide you with an applicable and relevant solution.

    Greetings,
    Simon
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  10. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 10 Feb 2010 Link to this post

    hi,

    i already pasted the aspx grid column code in the 3rd post. i repaste it here for you so u dont have to search it:

    <telerik:GridTemplateColumn HeaderText="inUse" UniqueName="inUse" ItemStyle-Width="36px">  
           <ItemTemplate>  
                   <telerik:RadToolTip ID="tipInUse" runat="server"   
                             TargetControlID="imgInUse" AutoCloseDelay="60000" >  
                   </telerik:RadToolTip>  
                   <asp:Image runat="server" ID="imgInUse" Width="20px" Height="20px"/>  
                   <asp:TextBox ID="txbInEditMode" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"is_ineditmode").ToString() %>' />  
                   <asp:TextBox ID="txbIsCheckedout" runat="server" Visible="false" Text='<%# DataBinder.Eval(Container.DataItem,"is_checkedout").ToString() %>' />  
            </ItemTemplate>  
     </telerik:GridTemplateColumn>  

    here u see the image. in code behind i read out the txbes to be able to set the correct inuse image_url (there are 2 diffenrent images, one for in use and one for not in use).

    i want to filter these two imageurls.

    cheers mario


  11. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 16 Feb 2010 Link to this post

    Hi Mario,

    Thank you for the clarification.

    In order to achieve your goal you need to:
    • Handle the client-side SelectedIndexChanged event of the Filter RadComboBox.
    • In the event handler of the event manually filter the Owner Table View by the column specifying whether a row is in use or not.
    Here is a similar example, an excerpt from this demo:

    <FilterTemplate>
        <telerik:RadComboBox ID="RadComboBoxTitle" DataSourceID="SqlDataSource2" DataTextField="ContactTitle"
            DataValueField="ContactTitle" Height="200px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ContactTitle").CurrentFilterValue %>'
            runat="server" OnClientSelectedIndexChanged="TitleIndexChanged">
            <Items>
                <telerik:RadComboBoxItem Text="All" />
            </Items>
        </telerik:RadComboBox>
        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
     
            <script type="text/javascript">
                function TitleIndexChanged(sender,args) {
                    var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                    tableView.filter("ContactTitle",args.get_item().get_value(),"EqualTo");
                     
                }
            </script>
     
        </telerik:RadScriptBlock>
    </FilterTemplate>

    The first parameter of the TableView.filter method is the name of the column by which to filter.

    I hope this hint will get you in the right direction.

    Sincerely yours,
    Simon
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017