Sorting with OpenAccessDataSource

23 posts, 0 answers
  1. Brandon
    Brandon avatar
    20 posts
    Member since:
    Nov 2007

    Posted 17 Dec 2008 Link to this post

    I am using the latest version of Telerik Q3.2008 with Visual Studio 2008.  I am unable to get the OpenAccessDataSource object to sort its results.  I have created the following Region object:

        [Telerik.OpenAccess.Persistent(IdentityField = "id")] 
        public class Region 
        { 
            private int id; 
            [Telerik.OpenAccess.FieldAlias("id")] 
            public int Id 
            { 
                get { return id; } 
                set { id = value; } 
            } 
     
            private string regionName; 
            [Telerik.OpenAccess.FieldAlias("regionName")] 
            public string RegionName 
            { 
                get { return regionName; } 
                set { regionName = value; } 
            } 
     
            private DateTime? lastModified; 
            [Telerik.OpenAccess.FieldAlias("lastModified")] 
            public DateTime? LastModified 
            { 
                get { return lastModified; } 
                set { lastModified = value; } 
            } 
        } 

    On my WebForm I have dropped an OpenAccessDataSource object.  I have set the DataSource's OrderExpression property to 'RegionName.'  Finally, I have tied my DataSource to a RadGrid.  However, the results are not sorted by RegionName.  What must I do to sort these properly?

  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 18 Dec 2008 Link to this post

    Hello Brandon,

    We reproduced the fault behavior locally and verify it as a problem. The bug was immediately fixed by our team and you can expect it as a part of our next service pack which is scheduled for release in the beginning of the next year. In the meantime i suggest you to use the AllowSorting property of the RadGrid as a workaround. Just set it to true and then you can use the grid to sort the content.

    Greetings,
    Zoran
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft banner
  4. SuperXRAY
    SuperXRAY avatar
    82 posts
    Member since:
    Feb 2007

    Posted 21 Mar 2009 Link to this post

    I have a RadGrid on a page with an OADS, and sorting and/or filtering does not work at all. The grid acts as though it is doing the work, but it never changes (never actually sorts or filters). If I group the items first, then I can sort...still can't filter. There are 1000, paging enabled.

  5. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 23 Mar 2009 Link to this post

    Hello Mitch,

    The problem you reported was evaluated by our team.  The bug will be fixed for our next service pack. Your telerik points were updated.

    If you have any other issues/suggestions please feel free to contact us again.


    Kind regards,
    Zoran
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. richardFlow
    richardFlow avatar
    62 posts
    Member since:
    Jun 2012

    Posted 24 Mar 2009 Link to this post

    Hi,

    I too am having problems with sorting, filtering and updating when using OADS.  Is there a bug with the Q1 release?

    I can page, but the sorting or filtering never works. The page refreshes, and on a sort the column is highlighted, but the order does not change.

    Regards,

    Richard.
  7. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 24 Mar 2009 Link to this post

    Hello Web Belief Ltd,
    Yes this is a verified problem with our latest release and we are working on solving the problem.

    Regards,
    Dimitar Kapitanov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  8. richardFlow
    richardFlow avatar
    62 posts
    Member since:
    Jun 2012

    Posted 25 Mar 2009 Link to this post

    Hi,

    Could you please clarify the full extent of the problem. I'm not very experienced with the RadGrid and our company has decided to use it as a prominent data entry and maintenance tool.  My problem is I don't know just how easily it should automatically allow paging, sorting, editing deleting etc.and none of them seem to work?  Is it my fault or the bug? Are all these features not working automatically?

    When is the fix due?  Will there be a patch before your next proper release?

    Regards,

    Richard.
  9. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 25 Mar 2009 Link to this post

    Hi Web Belief Ltd,
    We will release a service pack release latest two weeks from now. It will contain all required functionality for the datasource. The problem was recently discovered and is caused by internals of the datasource that handle the parameters required for sorting and filtering functionality.

    Regards,
    Dimitar Kapitanov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  10. richardFlow
    richardFlow avatar
    62 posts
    Member since:
    Jun 2012

    Posted 25 Mar 2009 Link to this post

    Thanks Dimitar,

    Is the updating functionality affected?  Should i expect it to just work? or do i need to do more programming that just pointing the datagrid to a updateable datasource?

    Regards,

    Richard.
  11. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 25 Mar 2009 Link to this post

    Hello Web Belief Ltd,
    I believe the updates should not be affected.

    Best wishes,
    Dimitar Kapitanov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  12. Brandon
    Brandon avatar
    20 posts
    Member since:
    Nov 2007

    Posted 25 Mar 2009 Link to this post

    You need to set the 'AllowAutomaticUpdates/Inserts/Delete' property to true on the grid.
  13. SuperXRAY
    SuperXRAY avatar
    82 posts
    Member since:
    Feb 2007

    Posted 06 Apr 2009 Link to this post

    How was something like this (sorting) simply left out of the release?

    A DataSource that can't sort isn't a DataSource at all.
  14. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 07 Apr 2009 Link to this post

    Hi SuperXRAY,
    Please help us understand what your current problem is as the datasource was tested thoroughly and we believe it works as expected.

    Best wishes,
    Dimitar Kapitanov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  15. SuperXRAY
    SuperXRAY avatar
    82 posts
    Member since:
    Feb 2007

    Posted 09 Apr 2009 Link to this post

    Well, I have already posted in this thread with the details and Telerik's first response was:

    ----------------------------------------
    Hello Mitch,

    The problem you reported was evaluated by our team.  The bug will be fixed for our next service pack. Your telerik points were updated.

    If you have any other issues/suggestions please feel free to contact us again.


    Kind regards,
    Zoran
    the Telerik team
    -----------------------------------------

    Then, the next response about it from Telerik was:

    -----------------------------------------
    Hello Web Belief Ltd,
    Yes this is a verified problem with our latest release and we are working on solving the problem.

    Regards,
    Dimitar Kapitanov
    the Telerik team
    -----------------------------------------

    And then...

    -----------------------------------------
    Hi Web Belief Ltd,
    We will release a service pack release latest two weeks from now. It will contain all required functionality for the datasource. The problem was recently discovered and is caused by internals of the datasource that handle the parameters required for sorting and filtering functionality.

    Regards,
    Dimitar Kapitanov
    the Telerik team
    -----------------------------------------

    I downloaded the latest release of OpenAccess hoping it would fix other bugs, but it did not. I read through the change documentation for the release (2009.1.405.1) and noticed it mentioned "OpenAccessDataSource: Filtering and Ordering work as expected". I'm curious since the verbage says "...Ordering...", is the OADS writing SQL Queries with ORDER BY clauses or is it implementing sorting through object functions? I have not tested the sorting as of yet for the new release.
  16. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 10 Apr 2009 Link to this post

    Hello SuperXRAY,
    When saying 'ordering' we are referring to the OrderBy property of the data source. It is translated to ORDERBY clause in the OQL and then it is executed against the db server. It means that the ordering takes place on the server. The internals are that the sorting expression from the grid and the ordering clause are merged together providing an unified 'sorting' OQL representation. The sorting expression is put at the start of the string so it should take precedence when ordering/sorting (basically the same, but it comes from different places). We have a range of tests exactly that incorporate RadGrid with a data source that is sorting and all of them pass so far. Please if you discovered additional problems share them with us so that we could improve the quality of the data source components.
    Hope my answer sheds some light on the topics you are refering.

    Greetings,
    Dimitar Kapitanov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  17. Brandon
    Brandon avatar
    20 posts
    Member since:
    Nov 2007

    Posted 10 Apr 2009 Link to this post

    I might add that the aforementioned service pack was released on the 6th of April :)
  18. Andrew
    Andrew avatar
    70 posts
    Member since:
    Oct 2008

    Posted 02 Jun 2009 Link to this post

    Hi,

    I am using OA 2009.1.520.1 with WebUI 2009.1.514.35, and at the moment can't get filtering (using grid filters) to work - as described above, the page refreshes (or the ajax loading panel is displayed), but no actualy filtering is applied. Tried with numeric and simple bound columns.

    Sorting does appear to work but, if the OA Datasource has an order by attached, and the same column is used for a user originated sort, there is an error reported.

  19. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 03 Jun 2009 Link to this post

    Hello Andrew,
    we worked with the latest official builds available for download of both OpenAccess and Rad Controls and we were not able to reproduce this behavior. Both filtering and sorting worked fine for us.
    </telerik:RadGrid><telerik:OpenAccessDataSource ID="OpenAccessDataSource1"  
                runat="server" ContextTypeName="" EnableDelete="True" EnableInsert="True"  
                EnableUpdate="True"  
                ObjectContextProvider="ClassLibrary33.ObjectScopeProvider1, ClassLibrary33"  
                OrderBy="@Ord1 DESC,@Ord2 ASC" TypeName="ClassLibrary33.Order" Where=""
                <OrderByParameters> 
                <asp:Parameter Name="Ord1" DefaultValue="Freight" /> 
                <asp:Parameter Name="Ord2" DefaultValue="Freight" /> 
                </OrderByParameters> 
            </telerik:OpenAccessDataSource> 
    Defining the data source like this resulted in perfectly proper behavior. Even when we tried to sort on the field Freight everything worked perfectly fine. Filtering worked as expected as well.
    Can you please confirm that you are using the latest available builds.

    Greetings,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  20. Andrew
    Andrew avatar
    70 posts
    Member since:
    Oct 2008

    Posted 03 Jun 2009 Link to this post

    Hi,

    Thanks for response - I may have misread this a bit, my problem occurs after linking a grid to the openaccessdatasource adn then allowing filtering on the gird. Perhaps this is a different issue.

    Deffo using the latest (or very near latest) verisons.
  21. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 09 Jun 2009 Link to this post

    Hello Andrew,
    you should be able to do that freely. We have tested it several times and we could not reproduce the false behavior.
    Typically the steps are as fallows:
     You create a class library and reverse map your classes.
     Refer that class library in your web application.
     Define the datasource as the example I gave in my previous post.
     Specify the grid data source property to be your newly created data source.
     Enable all properties that you find necessary on the grid.
     Run your application.
    The above steps should be enough to produce a working example. If you are still facing difficulties can you please open a support thread where our team can attach a working project for you.

    Kind regards,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  22. Andrew
    Andrew avatar
    70 posts
    Member since:
    Oct 2008

    Posted 09 Jun 2009 Link to this post

    Hi Petar,

    Thanks for response, you are quite right, if the OADataSource is decalred using the TypeName property, then the filtering works. But I am using the CommandText property, and that seems to prevent filtering (or ordering) from the RadGrid. Sorry for not saying this earlier.

    I wanted to use the CommandText property in order to display composite data from the OA classes.

    Using the TypeName to refer to a class permits access to the properties of the class, and of classes which are (Parents) of the class (Parents in terms of the hierarchy), but I also want to get to summary and selected properties of child classes.
  23. Andrew
    Andrew avatar
    70 posts
    Member since:
    Oct 2008

    Posted 09 Jun 2009 Link to this post

    Further to this, I have reverted to using a TypeName, my Class structure comprises an "Account" which has a parent class of "Product", and Product has a property called "FixedYears (Fixed_Years in the database)", when I put a column on my gird to display the Product.FixedYears, I can filter by it, but when I sort I get an error with the pertinent part of the StackTrace as follows:

    SELECT  TOP(??T) a.[Fndr_ID] AS COL1, a.[Loan_ID] AS COL2, a.[Completion_Date] AS COL3, a.[Locked_to_Swap] AS COL4, a.[Principal_Balance] AS COL5, a.[Product_ID] AS COL6, a.[Fndr_ID] AS COL7, a.[Pool_ID] AS COL8, a.[Swap_List_ID] AS COL9 FROM [Account] a JOIN [Product] AS b ON (a.[Product_ID] = b.[ID]) WHERE b.[Fixed_Years] = 2 ORDER BY  FixedYears   Telerik.OpenAccess.RT.sql.SQLException: Invalid column name 'FixedYears'
     

    Note that the Order By attempts to refer to a column called "FixedYears" which does not exist (the Product Class Property is FixedYears, but this maps to Fixed_Years in the database).

    I think I must point out that when I say filter and sort, I mean that I have enabled these options on the RadGrid and am exercising them from the grid (i.e. what a user would do).

    And Yes this happens for any property of a parent class of the TypeName class.

    Arrg - too quick to post, forget this problem - the Grid's SortExpression has to include the Parent Class (Product.FixedYears)..
  24. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 16 Jun 2009 Link to this post

    Hi Andrew,
    we are very happy that you have managed to figure it out. And now let me give you some insight on the CommandText problem. The issue comes from that the CommandText lifts the limitation of display a certain table in the grid. Giving this the grid cant "know" what will be returned from the data source using the CommandText. You can at first return customers than orders and so on. Because of that the grid columns cant be bound to a certain result thus enabling sorting. You can however set the data source like this:
    telerik:OpenAccessDataSource ID="OpenAccessDataSource1" runat="server"  
                ContextTypeName="" EnableDelete="False" EnableInsert="False" EnableUpdate="False"  
                ObjectContextProvider="ClassLibrary3.ObjectScopeProvider1, ClassLibrary3"  
                OrderBy="@param asc" TypeName="" Where="" CommandText="Select * From CustomerExtent"
                <OrderByParameters> 
                <asp:Parameter Name="param" DbType="String" DefaultValue="City" /> 
                </OrderByParameters> 
            </telerik:OpenAccessDataSource> 
    This way you will be able to pass the sorting parameter from a server control or query parameter( You have several options here, just review all the available parameters in the orderby tag).
    Hope that my response will help you.

    All the best,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner