Get filtered DataSource after pressing search button

7 posts, 0 answers
  1. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 25 Mar 2015 Link to this post

    Good afternoon,

    I'm working on a search box that filters the information from an EntityDataSource.
    I am looking for a solution that gets you the "final" DataSource, I mean the data collection that you can read after putting some letters in the search box.

    Is there any way to get it?

    Thank you for your attention



  2. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 27 Mar 2015 Link to this post

    Hi archimede,

    You can use the OnSearch server side event which is raised when the search button is clicked, Enter is pressed or an item from the searchbox dropdown is  clicked. The event handler receives two parameters:
    1. The instance of the SearchBox firing the event
    2. An event arguments parameter that contains the following properties:
      • Text - returns the text that is typed in the searchBox, or the text of the selected result item.
      • Value - returns the value of the selected result item.
      • DataItem - returns the dataItem that is associated with the selected result item.
    Then in the event handler you can filter the data source using the searched text and thus get the returned data collection.

    Please check the following online example demonstrating similar scenario (you can do this also using EntityDataSource):
    http://demos.telerik.com/aspnet-ajax/searchbox/examples/applicationscenarios/gridfilteredbysearchbox/defaultcs.aspx

    Regards,
    Aneliya Petkova
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 01 Apr 2015 in reply to Aneliya Petkova Link to this post

    Hello Aneliya,

    thank you for your answer.
    I tried to follow your example using the EntityDataSource but the DataItem is always null, so I can't have any information about my searching results.

    Do you have any clue or other things I should add in order to retrieve the requested DataItem?

    Thank you
  5. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 01 Apr 2015 in reply to archimede Link to this post

                <telerik:RadSearchBox runat="server" 
                    ID="RadSearchBox1" 
                    EmptyMessage="Cerca..."
                    DataSourceID="EntityDataSource1" 
                    DataValueField="IdHelp"
                    DataTextField="DatiHelp" 
                    DataKeyNames="DatiHelp, IdHelp"
                    Width="300"
                    EnableAutoComplete="true"
                    OnClientSearch="lookForResults" 
                    OnSearch="DisplayResults" >
                    <DropDownSettings Height="400" Width="300" />
                </telerik:RadSearchBox>

        <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=DMWEntities"
                DefaultContainerName="DMWEntities" EntitySetName="Manuale_Machina" Select="it.[IdHelp], it.[DatiHelp], it.[Titolo]"
                AutoPage="true ">
        </asp:EntityDataSource>

     

    I used this code in order to use RadSearchBox, if this can help. (I also tried the SQLDataSource, but it returns the same error)


  6. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 03 Apr 2015 Link to this post

    Hi archimede,

    I can't see anything wrong with the code snippet you sent.
    I made you a sample using EntityDataSource. Please try it and let me know if everything works ok at your side.

    Regards,
    Aneliya Petkova
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  7. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 22 Apr 2015 in reply to Aneliya Petkova Link to this post

    Hello,

     I tried your example and I have the same settings, for the EntityDataSource and for the object SearchBox, but I didn't get what I wanted.

    Is there any possibility of retrieving the entire collection of DataItems that are showing while writing on the searchbox?

    The scenario could be simulated in this way: I click on a single result and I get a DataItem, so I should click on all results to get the collection that I am looking for.

     

    Thank you

  8. Aneliya Petkova
    Admin
    Aneliya Petkova avatar
    207 posts

    Posted 23 Apr 2015 Link to this post

    Hi archimede,

    I am not sure I understand what exactly you need to achieve and why you want to get all the filtered data. But this it is not possible using RadSearchBox control. You can try some other controls - for example RadComboBox and see if it will be suitable for your scenario.

    Regards,
    Aneliya Petkova
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017