locked
Standard sorting for table? RRS feed

  • Question

  • Hello,

    some of my lookup tables for my autocomplete boxes should be sorted in alphabetical order - I know that it is possible to add querys to the tables and then those to the screen and change the source of the autocomplete boxes to that querys.

    but isn't there an easier way to have all access to that table sorted without adding querys and additional dataelements to screens?

    robert

    Tuesday, January 8, 2013 12:21 PM

All replies

  • Hi Mad,

    I'm pretty sure that if you wanted to have your data sorted, you would need to specify the column in the table and the ordering (ascending or descending) which would require a query to do the work.

    Is there a reason why you are avoiding the query path?

    -Pierson

    Wednesday, January 9, 2013 12:44 AM
    Moderator
  • If every time you use a particular table you want the records sorted in a particular way, you can create a TableName_All_PreprocessQuery method. Any scree where the table is used, or in any query based on the table, the sort order will be in effect. The key is the All part of the name.

    Zum Beisspiel:

    Private Sub MyTableName_All_PreProcessQuery(ByRef query As System.Linq.IQueryable(Of MyTableName))
        query = _
            from q in query
            order by q.SomePropertyName
    End Sub

    In LS 2011, the All methods were available in the Write Code dropdown box in the table designer. I believe that's been removed in LS 2012, but you can still write the code manually.

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Proposed as answer by Xpert360 Wednesday, January 9, 2013 7:39 AM
    • Unproposed as answer by Xpert360 Thursday, January 10, 2013 10:54 AM
    Wednesday, January 9, 2013 12:58 AM
    Moderator
  • Hello Yann,

    Are you sure this works in LS 2012?

    if I place such a Sub in my DataService class this method will not be called by LS

           Private Sub Aktzustand_All_PreProcessQuery(ByRef query As System.Linq.IQueryable(Of AktzustandItem))
                query = _
                    From q In query
                    Order By q.Aktzustand
            End Sub

    where to place this?

    robert

    Wednesday, January 9, 2013 8:04 AM
  • Well, I *was* sure, but I just tried it, & indeed it would seem that for a new LS 2012 project, the All_PreProcessQuery methods no longer work. They were said to be deprecated, but that usually means that another method is favoured over the original (with the eventual phasing out of the original). It doesn't normally mean that the functionality gets ripped out immediately, so I was mislead by that.

    "The inferred modelled query (eg Companies_All) that represented the EntitySet was deprecated.  This implies its Preprecess query was deprecated (eg Companies_All_PreprocessQuery) 

    If you want to define a default sort, you will need to create a modeled query that defines the sort and use that in the places where you want the data sorted.  Keep in mind that the inferred modeled query that represents the EntitySet (eg Companies_All) will be maintained in upgraded projects so your existing projects will behave just as they did in V1"

    I found this thread that gives an explanation:

    With <EntitySet>_All PreprocessQuery deprecated, how do we specify a default sort order?


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Wednesday, January 9, 2013 2:46 PM
    Moderator
  • OK - that means I must add the sorted query to every screen to have sorted autocomplete boxes - what an overhead...

    they removed functionality which was perfect for sorting the table?? I cannot understand the reason...

    robert

    Wednesday, January 9, 2013 3:08 PM
  • Yes, it would appear that's what you need to do. It's not a big deal though. I've been routinely doing this for each list screen that I have. Sometime there might be 2 or 3 different ways that the same data needs to be sorted, depending where it's being displayed (by date in one screen, by name in another, or by team in yet another). An All_PreProcessQuery method wouldn't have helped in that situation at all, I'd still need three modelled queries, all based on the same table.

    I must admit, that I don't understand the reasoning behind actually removing the functionality, instead of just deprecating it in favour of some new method, then much later removing the actual deprecated functionality.

    But you do seem to keep forgetting ALL of what LightSwitch does FOR you, & only see what things you have to do yourself, if you want an experience that's different from out-of-the-box.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Wednesday, January 9, 2013 3:35 PM
    Moderator
  • Hello Yann,

    My experiences with LS are not so good - maybe it is not the right tool for my project but my customers has a lot of requirements which I have to solve and with LS it is not easy or not possible

    but I have to live with that - and that's not the biggest problem but the worse performance make things not better...

    robert

    Wednesday, January 9, 2013 3:53 PM
  • LightSwitch was never intended for professional developers to write applications to then sell to clients. That's why some of the ways that it does things grate on the nerves of professional developers.

    Are professional developers doing just that anyway? Yes, they are. But it really depends on what you need to do with LightSwitch, & the approach taken, whether the experience will be a quick & pleasant one, or somewhat of a nightmare.

    I don't know whether LightSwitch is, or isn't, the right tool for your current requirements, but I do feel (very strongly) that your approach to using LightSwitch is causing you some of your disappointment (no offense intended).

    By all means keep feeding the team information about any poor performance (but it has to be something that they can readily reproduce, it can't be vague "LS is slow" type of comments). This will benefit everyone if they can find the bottlenecks & fix them. But for your own sanity, I would suggest that you start working with LightSwitch's strengths (if which it has MANY), rather than focusing so much on its shortcomings (& yes, it has shortcomings as well).

    This is all just my opinion though, so feel free to disagree with anything that I'm saying.

    I only say these things, with the hope that a shift in expectation &/or approach, will result in a better LS experience for you. I hope you will take my comments in the way they're intended.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, January 10, 2013 1:26 AM
    Moderator
  • Hello Yann,

    I agree in the most point's and it was my fault to use LS for my project and find later that there are so many problems...

    but the point is that I have posted many problems - especially about the speed problems - with detail description (the Datagrid is the performance killer) and got no feedback or response from the LS Team

    and also not having a roadmap makes it difficult to plan - for my feeling I think LS has no great future because there are no new Extensions/Shells/Themes since months and also the 3 party control companies stopped enhancing there controls (ComponentOne, Infragistic..)

    robert

    Thursday, January 10, 2013 8:27 AM
  • I wasn't blaming you for using LightSwitch, or even criticising your decision. I just wish your experience had been more pleasant one. I think Microsoft were very much caught by surprise by the level of interest from professional developers. Now they're faced with the problem of enabling as much functionality as they can, yet remaining true to LightSwitch's roots at the same time. It can't be easy, especially if those "higher up" are pulling the strings.

    LightSwitch does what it was designed to do extremely well, yet has the flexibility to extend it in ways that weren't envisioned at the time of writing it. But you have to put in some work (code) to achieve that.

    I stopped writing/releasing extensions myself (controls, themes, shells, business types etc), because every time I announced I was planning to release an extension, someone else would "beat me to it" (before I could finish the documentation), some on purpose some by pure accident. Co-writing the book also took a LOT out of me, & I've really only started to recover in the last six months or so. But I certainly plan on releasing more extensions.

    As for not getting a response, sometimes the team is just busy fixing bugs, or writing vNext. And sure, they often don't communicate with us as well as we'd like, but there are more than likely times when they're not allowed to. But I do see a current effort to find & fix major problems.

    I don't know for sure, but I can almost guarantee that there's work going on around improving performance. Just because you don't hear what's going on doesn't mean that nothing is. But I do concede that it's frustrating not knowing what's happening.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Thursday, January 10, 2013 10:41 AM
    Moderator
  • > ...also the 3 party control companies stopped enhancing there controls (ComponentOne, Infragistic..)

    Updated on 2-Jan-2013: ComponentOne

    ComponentOne Studio for LightSwitch

    We are testing and developing tools too.

    I'll agree with you on the item of 'Roadmap', that stifles growth of the LightSwitch market space and is not good for anyone.

    However, LightSwitch is a very capable tool, will improve over time, and today delivers significant cost saving in projects for us.


    Dave Baker | Xpert360 blog | twitter : @xpert360 Opinions are my own. Please mark as answer if this helps solve your problem.


    Thursday, January 10, 2013 3:10 PM