Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

GUI - Listbox dynamically sorting ?

Community Beginner ,
Jun 13, 2016 Jun 13, 2016

Hi

i'm doing my first steps into the scripting world, following David Torno's course (great course BTW, thanks a lot!!!)

and i'm trying to put what i've learned into a script that will have "a better render queue", meaning you can see quickly all of your renders, their outputs, when they were rendered, etc.. (the next step will be to export the into excel or something like that..), i'm using Listbox to show all the items, and I was wondering if there's a way to sort the list by different columns headers dynamically (e.g. render path output, date rendered, etc..).

i'd be happy for any help or direction because i couldn't find anywhere online or written info on this (sort listbox) matter.

thanks

D

here's what i got so far:

try{

   

    var proj = app.project;

    var totalRenderQ = proj.renderQueue.numItems;

    var rqList = new Array();

    var totalOM;

   

    var FSWindow = new Window("palette","Listbox Scroll Bug", undefined,{resizeable:true});

            FSWindow.alignment = ["fill","fill"];

            FSWindow.alignChildren=["fill", "fill"];

    var FSGrp =  FSWindow.add("group", undefined, "groupList"); 

            FSGrp.orientation = "column";

            FSGrp.alignChildren = ["fill","fill"];

    var quitBtn = FSGrp.add ("button", undefined, "Close");

            quitBtn.onClick = function() {    

                                                        FSWindow.close();    

                                                        }  

    var FSList = FSGrp.add("listbox", [0,0,1200,800], "FS List", {multiselect:true,  numberOfColumns: 5, showHeaders: true, columnTitles: ["Render #","Date","Time", "Comp Name", "Render Path"]});

    for (var i= 1; i<=totalRenderQ;  i++){

            totalOM= proj.renderQueue.item(i).numOutputModules;

                    for (var om= 1; om<=totalOM; om++){

                                rqList[rqList.length] = "Render #" + i + " - " + om  +": " + proj.renderQueue.item(i).outputModule(om).file.toString();

                                var dateList, timeList, curItem;

                                if (proj.renderQueue.item(i).startTime != null){

                                            var min = proj.renderQueue.item(i).startTime.getMinutes() <10 ? "0"+ proj.renderQueue.item(i).startTime.getMinutes() : proj.renderQueue.item(i).startTime.getMinutes();

                                            var year = proj.renderQueue.item(i).startTime.getFullYear().toString().substr (-2,2);

                                            timeList = (proj.renderQueue.item(i).startTime.getHours()-1)+":" + min;

                                            dateList =proj.renderQueue.item(i).startTime.getDate()+"/"+(proj.renderQueue.item(i).startTime.getMonth()+1)+"/"+year ;

                                }else{     

                                        dateList = "not rendered";

                                        timeList = "    ";

                                    }

                                curItem = FSList.add ('item', "Render #" + i + " - " + om );    // Column 1

                                curItem.subItems[0].text = dateList.toString();                         // Column 2

                                curItem.subItems[1].text = timeList.toString();                          // Column 3

                                curItem.subItems[2].text = proj.renderQueue.item(i).comp.name; // Column 4

                                curItem.subItems[3].text = proj.renderQueue.item(i).outputModule(om).file.toString().replace(new RegExp(",","g"), "\r").replace(new RegExp("%20","g"), " ").replace(new RegExp("%5B","g"), "[").replace(new RegExp("%5D","g"), "]"); // Column 5   

                                itemNum ++;

                            }

     }

FSWindow.layout.resize();     //Resizes layout

FSWindow.onResizing = FSWindow.onResize = function () {this.layout.resize();}     //Resizes everything with panel

FSWindow.layout.layout(true);

FSWindow.center();

FSWindow.show();

}

catch(err){

    alert ("Error at line # " + err.line.toString() + "\r" + err.toString());

    }

TOPICS
Scripting
565
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 24, 2016 Jun 24, 2016

What you have to do is create an Object array from your data. This way you can run a sorting function to the array based on which column you want ordered. It's involves removing all list items, sorting, then repopulating the listbox each time it's sorted. Also you will need radio buttons to trigger the sorting column choice. The headers of a listbox don't trigger an onClick event. Decently involved to do, but should be doable.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 25, 2016 Jun 25, 2016
LATEST

cool, it's a pity that it's not "out of the box" solution, but for now (and for my skills) it's a bit over the top, i'm planning on getting there.

in the meanwhile i added a search function that does the work (even better then sorting i wanted), but i'll keep that in mind when i'll have the itch to add sorting option in the future.

thanks!!

D

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines