Collection list sorting

Discussion in 'Tally Developer' started by Rupal Agarwal, May 6, 2023.

    
  1. Rupal Agarwal

    Rupal Agarwal Member


    Hello everyone,

    I have created a collection list, but now I want to sort it according to the order I have written them in collection.

    Code:
    [Collection: Ns Time]
        Title        : "Student Timings"
        List Name    :  "7 AM", "8 AM", "9 AM", "10 AM", "11 AM", "12 Noon" , "1 PM", "2 PM", "3 PM", "4 PM", "5 PM", "6 PM",               
        Align        : Right
        Full Height    : Yes
        Format        : $Name, 10
    
    But its coming as :
    Screenshot 2023-05-06 142211.jpg I want it as 7 Am to 7 PM in order
     


  2. Himanshu-2002

    Himanshu-2002 Active Member


    Do it like this

    [Object:a]
    Name:"7 AM"
    SortIndex:1

    [Object:b]
    Name:"8 AM"
    SortIndex:2

    [Collection:ListOfMyObjects]
    Object:a,b
    Sort:mad:@Default:$SortIndex
     


  3. kosi

    kosi Member


    This is great but u need to learn more on how to fetch collections using tdl codes.
    Creat the values (7am to 8am) in tally database and fetch these values using collection to the desired field
     


  4. Rupal Agarwal

    Rupal Agarwal Member


    Thank u sir replying.
    Please can you elaborate more.
     


  5. Rupal Agarwal

    Rupal Agarwal Member


    This method will be long when the list items are in the last quantity. Please provide any short way if possible.
     


  6. Himanshu-2002

    Himanshu-2002 Active Member


    Yes, This method would be long if you have many items So, The shortest way would be using "DateTime" Data type of tally in which User can enter time easily

    [Field:abc]
    Type:DateTime
     


  7. Devendra_Rawat

    Devendra_Rawat Well-Known Member


    [Collection: Ns Time]
    Title : "Student Timings"
    List Name : "1. 7AM", "2. 8AM", "3. 9 AM", "4. 10 AM", "5. 11 AM", "6. 12 Noon" , "7. 1 PM", "8. 2 PM", "9. 3 PM", "10. 4 PM", "11. 5 PM", "12. 6 PM",
    Align : Right
    Full Height : Yes

    Format : $Name, 10

    You can use $$Number and $$stringPart function in compute to display only 7 AM , 8 AM etc in collection
     


  8. Rupal Agarwal

    Rupal Agarwal Member


    Not Working
     


  9. Rupal Agarwal

    Rupal Agarwal Member


    please explain more
     


  10. Amit Kamdar

    Amit Kamdar Administrator Staff Member


    You must have not implemented the LAST line .... as directed.
     


  11. Devendra_Rawat

    Devendra_Rawat Well-Known Member


    Date Field.png This should work


    Code:
    
    [Collection: Ns Time Src]
    
        List Name : "01. 07 AM", "02. 08 AM", "03. 09 AM", "04. 10 AM", "05. 11 AM", "06. 12 OO" , "07. 01 PM", "08. 02 PM", "09. 03 PM", "10. 04 PM", "11. 05 PM", "12. 06 PM",
        Fetch    : Name
    
    
    [Collection: Ns Time ]
       
        Source Collection    : Ns Time Src
       
        Title        : "Student Timings"
        Compute      : Name      : $$StringPart:$Name:4:(($$StringLength:$Name)-3)
        Format      : $Name, 10
        Compute      : NameIndex : ($$StringPart:$Name:0:3)
    
        Table Sort  : $$Number:$NameIndex
        Full Height : No
    
    
     
    Last edited: May 11, 2023


  12. Rupal Agarwal

    Rupal Agarwal Member



    Thank you so much for replying. I tried the same thing and it worked perfectly for me :D.
     


Share This Page