What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Question] ListViewControl - Numeric sortable Columns

[Question] ListViewControl - Numeric sortable Columns
Author: Message:
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: [Question] ListViewControl - Numeric sortable Columns
This should take the text that you have in the List View and sort it by the column of your choice (numerically or by text).  I haven't tested it but it should work (I at least checked for syntax errors today 8-)).  I did have something else here but realised I needed to change the sort function for this to be possible.  I hope you like it.  If you want any more information about this (or find a bug) please don't be afraid to ask, you can find my email/WLM address in my profile.
code:
[...]

var PlusWnd;//The Plus/Child Window object that the List View is in
var ControlID;//the ControlId of the List View
var Col;//sort by this column number

[...]

//Get the text in the List View
var arr = new Array();
var i=0;
while(PlusWnd.LstView_GetItemText(ControlID,0,i)!=undefined){
   arr[i] = new Array();
   for(j=0;j<PlusWnd.LstView_GetCount(ControlID);j++){
      arr[i][j] = PlusWnd.LstView_GetItemText(ControlID,j,i);
   }
   i++;
}
//Remove all the text in the List View
while(PlusWnd.LstView_GetCount(ControlID)!=0){
   PlusWnd.ListView_RemoveItem(ControlID,0);
}
//Arrange the data in the correct order
for(i in arr){
   if(i!=Col){
      for(j in arr[i]){
         arr[i][j] = arr[Col][j]+" "+arr[i][j];
      }
      arr[i] = arr[i].sort(num);
   }
}
arr[Col][j] = arr[Col][j].sort(num);
for(i in arr){
   if(i!=Col){
      for(j in arr[i]){
         arr[i][j] = arr[i][j].replace(RegExp("^"+arr[Col][j]+"\s",""),"");
      }
   }
}
//Put text back into the List View
for(j in arr[Col]){
   PlusWnd.LstView_AddItem(ControlID,arr[Col][j],j,Col);
}
for(i in arr){
   if(i!=Col){
      for(j in arr[i]){
         PlusWnd.LstView_SetItemText(ControllID,j,i,arr[i][j]);
      }
   }
}

[...]

//method of sorting array
function num(x,y){
   x_value = parseInt(x);
   y_value = parseInt(y);
   if (x_value > y_value) return 1;
   else if (x_value == y_value) return 0;
   else return -1;
}

This post was edited on 01-13-2007 at 06:22 AM by markee.
[Image: markee.png]
01-13-2007 06:09 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[Question] ListViewControl - Numeric sortable Columns - by tryxter on 01-11-2007 at 11:00 PM
RE: [Question] ListViewControl - Numeric sortable Columns - by CookieRevised on 01-12-2007 at 04:59 AM
RE: [Question] ListViewControl - Numeric sortable Columns - by tryxter on 01-12-2007 at 11:31 AM
RE: [Question] ListViewControl - Numeric sortable Columns - by Mnjul on 01-12-2007 at 04:41 PM
RE: [Question] ListViewControl - Numeric sortable Columns - by markee on 01-13-2007 at 06:09 AM
RE: [Question] ListViewControl - Numeric sortable Columns - by CookieRevised on 01-13-2007 at 07:22 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On