Filtering in RadGrid with ObjectDataSource

12 posts, 0 answers
  1. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 28 May 2008 Link to this post

    I am using the RadGrid bound to an ObjectDataSource. Paging and sorting work out of the box, but filtering needs some extra work.

    I am handling the Selecting event of the ObjectDataSource, to put the FilterExpression in the InputParameters for the ObjectDataSource. However the filter expression in the MasterTableView is in a very odd format:
    (it["NAME"].ToString().StartsWith("ch"))
    which is next to useless, is this some badly set option of the grid? I basically just dropped it on the form.

    Also, the filter menu sort of works fine when you put in your filter criteria and click on the filter icon to select the filter type.
    However, if you type in the filter box and press enter, a filter menu opens in the top left hand corner of the page with different options than the one on the column. Is it possible to have it use the default filter type when you press enter? I have tried using and not using AutoPostback, and I have seen that the CurrentFilterFunction is set to StartsWith (which is what I want, I don't really want a postback).
    What is this other filter menu and how do I get rid of it?

    One final thing, the Selecting event seems to be fired twice, once for the Select and once (I guess) for the SelectCount call... Is this normal?

    Thanks. If someone is willing to help me I have a demo all ready to send / upload.

    Thanks.
    David
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 29 May 2008 Link to this post

    Hi David,

    You can set EnableLinqExpressions to false to get normal SQL like filter expressions. Indeed due to enabled paging ObjectDataSource.Selecting will be called twice.

    I tried to reproduce this unwanted post back on our filtering example and indeed the page will be posted on enter key press in the filter textbox. Luckily I found that this actually is caused by the post-back button below the grid - can you verify if this is not the case at your end?

    You can check also this thread which is very similar to your scenario:
    http://www.telerik.com/community/forums/thread/b311D-bdmmgc.aspx

    Greetings,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 29 May 2008 Link to this post

    Hi Vlad,

    Thanks for your response.

    In my case there are no other controls on the page at all, just the grid. Like I said, when you press enter, a filter menu pops up (is this the correct behavior?) then when you choose one option (not all the options are available) it does a postback and the filterExpression is NOT populated. After the postback the filter text box is empty.
    It looks worse on firefox than on explorer, on firefox the menu is not in the correct location, it is on the top left hand corner of the page.

    BTW, I find it unnecessarily difficult to use a lot of the examples on the telerik website, only because they do not contain project files, and often have links to aspx files that are not provided (like the header etc in the example you pointed me to). Of course all these issues are easily resolved, but why do i have to do that? Why can't you just give us a simple, working example project? The live demo site I have not been able to get working on VS 2008.


    Thanks.
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 30 May 2008 Link to this post

    David,

    The example can be found in the thread I posted in my previous reply.

    All the best,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 30 May 2008 Link to this post

    Yes I did see that thread. Indeed, I had already found it before I bothered to spend the time to ask my own question directly.

    As I mentioned in my last post, the examples given are not totally useful - they do not contain PROJECT files, so have to be modified to compile and run. If it were me I would be giving out examples that could be unzipped and run, as it stands I am now going to have to install SQLEXPRESS, load up the northwind database, etc just to run your example...

    After said modification, i see that is kind of works, though does nothing when you press enter. Also there is a dll shipped with your example, what is that? The assembly registered when I drop the RadGrid control onto my form is:
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

    Am I missing something here? Can you not just drop the RadGrid onto the form and have it work? Thanks for your help.
  7. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 30 May 2008 Link to this post

    Plus:

    If I change the assembly reference in your example to point to the installed version of the RadGrid, ie the one installed when I install the product (and add a script manager to the page like it says I have to), I get exactly the same result (odd menu popup on enter, works if you select the filter icon).

    Perhaps you could try installing your product and doing the same test? I installed RadControls_for_ASP.NET_AJAX_2008_1_515_trial.exe

    Thanks!
  8. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 30 May 2008 Link to this post

    (sorry, double post)
  9. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 03 Jun 2008 Link to this post

    Hello david,

    Basically, I would recommend using the latest version of the product available, to ensure that you take advantage of the latest bugfixed and functionalities. Is the issue with the menu appearing when running the project with the latest version of the control?
    Further, indeed some samples include SQL databases, and this is done due to popular demand, as many users utilize this option. Alternatively, you can replace the SQL datasource with an AccessDataSource, with the same query, and replace it as the original datasource for the control.
    Further, depending on the sample, you may have different references, some of which may not be valid. If this is the issue at your end, you can remove the references declarations from the page, and include only the ones pointing to your dlls.

    Sincerely yours,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  10. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 03 Jun 2008 Link to this post

    Well, I thought that was the latest version? I just downloaded it directly from this site... I just checked and the IS the latest version (released 5/15/2008). So yes, the problem is there when I use the latest version. Basically all I have done is taken the example you gave, and changed to references to use the dll installed with the latest version. Should I open a support ticket so I can upload my sample project? Actually, I think that is what I should do - I really need to get this sorted out pretty soon now.

    I understand about the database thing, in the end it's not too painful to install SQLExpress and download Northwind I guess. Thanks for your help.
  11. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 05 Jun 2008 Link to this post

    Hello?

    I am using the latest version.
    I drop the grid onto my web page, add my objectdatasource and set up the filtering and paging, and it does not work.
  12. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 06 Jun 2008 Link to this post

    Hi david,

    Indeed, to further investigate the issue, it would be best if you open a formal support ticket, and send us a small working project, demonstrating the issue, which we can debug locally, and advise you further.

    Greetings,
    Yavor
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. david
    david avatar
    34 posts
    Member since:
    May 2008

    Posted 06 Jun 2008 Link to this post

    Okay, Thanks I have done that now. The ticket ID is 142521.

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