forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Freeze Table Header

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous
View previous topic :: View next topic  
Author Message
briguy
Contributor
Contributor


Joined: 09 Aug 2007
Posts: 79

PostPosted: Wed Sep 28, 2011 3:21 am    Post subject: Freeze Table Header Reply with quote

All I thought I would share this.. I've been banging my head for the last few days trying to figure out how to lock / freeze the table header.

I have a large table with many columns and wanted to hide them without parsing them out. ok that worked with Aslans extTable dsu.. or codescripts table api but if you moved or re-sized the header the whole table magically reset it self..

So this is my solution.. I hope it helps someone and if any of you code gurus can clean up my code and make it better please do.

I want to thank Aslan for the extTable.dsu this wouldn't be possible for me to figure this out with out it.

This example includes drag and drop headers, double click text in cell to hide columns, lock headers, save and load table order.

I corrected some code also I remember that column 0 is flaky when you try to use tCol ORDERARRA when it is not hidden. fyi.


Code:


#INCLUDE extTABLE.DSU
#DEFINE function,string
EXTERNAL @path(%0)string.dll
Title FreezeTableHeaders
  DIALOG CREATE,New Dialog,-1,0,754,208
REM *** Modified by Dialog Designer on 9/27/2011 - 21:54 ***
  DIALOG ADD,TABLE,TABLE1,50,12,732,144,Column 0|Column 1|Column 2|Column 3|Column 4|Column 5|Column 6|Column 7|Column 8,,COLUMNSORT,DBLCLICK,
  DIALOG ADD,BUTTON,LockHeader,12,15,98,24,LockHeaders
  DIALOG ADD,BUTTON,SaveOrderArray,12,118,109,24,SaveOrderArray
  DIALOG ADD,BUTTON,Reset,13,328,64,24,Reset
  DIALOG ADD,BUTTON,LoadSavedArray,13,229,96,24,LoadSavedArray
  DIALOG SHOW
 
  TABLE EXTSTYLE,Table1,HEADERDRAGDROP|FULLROWSELECT|GRIDLINES
 
rem populate for the test..
  list add,table1,Test of table1@tab()dog food@tab()cat food@tab()fish food@tab()rat food@tab()I think I had to many tacos@tab()uhhh@tab()I really hope I dont get sick tonight@tab()end
  list add,table1,Test of table12@tab()dog food2@tab()cat food2@tab()fish food2@tab()rat food2@tab()I think I had to many tacos2@tab()uhhh2@tab()I really hope I dont get sick tonight2@tab()end2
 
 
:Evloop
  wait event
  goto @event()
 

 
:SaveOrderArrayBUTTON
INIFILE OPEN,@curdir()\tblset.ini
%%tblorder = @tCol(table1,ORDERARRAY)
%%headercount = @tCol(table1,COUNT)
%%sum = 0
repeat
  %%tblwidth = @tCol(table1,WIDTH,%%sum)
  INIFILE WRITE,TABLE1,tblwidth%%sum,%%tblwidth
  %%sum = @sum(1,%%sum)
until @equal(%%sum,%%headercount)

INIFILE WRITE,TABLE1,tblorder,%%tblorder
INIFILE CLOSE
%%sum =
%%tblwidth =
%%tblorder =
%%headercount =
goto evloop

 
:ResetBUTTON
INFO havent figured that out yet.. have to close and reopen your app if you locked your table.
   goto evloop
 
:LoadSavedArrayBUTTON
OPTION FIELDSEP,|

INIFILE OPEN,@curdir()\tblset.ini
%%tblordersaved = @INIREAD(table1,tblorder,)
tCol ORDERARRAY,table1,%%tblordersaved

%%headercount = @tCol(table1,COUNT)
%%sum = 0
repeat
  %%tblwidthsaved = @INIREAD(table1,tblwidth%%sum,)
  tCol WIDTH,TABLE1,%%sum,%%tblwidthsaved
  %%sum = @sum(1,%%sum)
until @equal(%%sum,%%headercount)
INIFILE CLOSE
%%sum =
%%tblwidthsaved =
%%tblordersaved =
%%headercount =
  goto evloop

:TABLE1DBLCLICK
%%sel = @tItem(Table1,SELECTED)
parse "%%item;%%Col", %%sel
tCol WIDTH,Table1,%%col,0
goto evloop


:LockHeaderBUTTON
REM THIS SETS THE LAST Column dlbclicked to 1 pixel wide required "other wise it will not lock correctly.
REM This must be done before using the Tcol FIXED,<table>,<col> call
  tCol WIDTH,Table1,0,1
rem ------------------------------------------------------------------------------

%%headercount = @tCol(table1,COUNT)
%%sum = 0
repeat
 tCol FIXED,Table1,%%sum
 %%sum = @sum(1,%%sum)
until @equal(%%sum,%%headercount)
%%sum =
  goto evloop
 
 
:Close

  exit


Last edited by briguy on Fri Sep 30, 2011 1:39 am; edited 1 time in total
Back to top
View user's profile Send private message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Thu Sep 29, 2011 10:24 pm    Post subject: Reply with quote

For RESET maybe just reconfigure the array from the last saved data in the inifile. However, once you set tCol Fixed there no why that I have found to dynamically turn it off without reloading the dialog.

Glad to see good use of extTable Very Happy
Back to top
View user's profile Send private message Send e-mail
briguy
Contributor
Contributor


Joined: 09 Aug 2007
Posts: 79

PostPosted: Fri Sep 30, 2011 1:26 am    Post subject: Reply with quote

If all the columns go fixed / locked with the exception of column 0 then that is because you have to set column 0 width to at least 1. I found that column 0 is the key to locking it the whole array.


Code:

tCol WIDTH,Table1,0,1


Aslan I cant get the Table STYLE,<table>,<style> to work I'm running vds 6 and windows 7 is this a known issue? I know the table control is "special" lol..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Miscellaneous All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group