Deleting column at runtime of a tabular datawindow.

Here is first few lines of a datawindow exported.

release 7;
datawindow(units=0 timer_interval=0 color=30457262 processing=0 HTMLDW=no print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 = 97 print.margin.bottom = 97 print.paper.source = 0 print.paper.size = 0 print.prompt=no print.buttons=no print.preview.buttons=no )
header(height=160 color="536870912" )
summary(height=0 color="536870912" )
footer(height=104 color="536870912" )
detail(height=88 color="536870912" )
table(column=(type=char(8) update=yes updatewhereclause=yes key=yes name=trans_id dbname="etlcoil.trans_id" validation="len( gettext() )=8" validationmsg="'Item ~~'' +  gettext()  + '~~' length must be 8'" )
 column=(type=char(6) update=yes updatewhereclause=yes name=stpl_tag_no dbname="etlcoil.stpl_tag_no" )
 column=(type=char(15) update=yes updatewhereclause=yes key=yes name=etl_coil_id dbname="etlcoil.etl_coil_id" )
 column=(type=datetime update=yes updatewhereclause=yes key=yes name=etl_date dbname="etlcoil.etl_date" )
 column=(type=decimal(3) update=yes updatewhereclause=yes name=thick dbname="etlcoil.thick" initial="0" )
 column=(type=decimal(0) update=yes updatewhereclause=yes name=width dbname="etlcoil.width" initial="0" )
 column=(type=char(4) update=yes updatewhereclause=yes name=coat_id dbname="etlcoil.coat_id" initial="0001" validation="len( gettext() )=4" validationmsg="'Item ~~'' +  gettext()  + '~~' length must be 4'" )
 column=(type=decimal(4) update=yes updatewhereclause=yes name=weight dbname="etlcoil.weight" initial="0" )
 column=(type=char(6) update=yes updatewhereclause=yes key=yes name=shift dbname="etlcoil.shift" )
 column=(type=char(2) update=yes updatewhereclause=yes name=finish_id dbname="etlcoil.finish_id" )
 column=(type=decimal(2) update=yes updatewhereclause=yes name=temper dbname="etlcoil.temper" initial="0" )
 column=(type=char(10) update=yes updatewhereclause=yes name=grade dbname="etlcoil.grade" )
 column=(type=decimal(4) update=yes updatewhereclause=yes name=start_cuts dbname="etlcoil.start_cuts" initial="0" )
 column=(type=decimal(4) update=yes updatewhereclause=yes name=end_cuts dbname="etlcoil.end_cuts" initial="0" )
 column=(type=char(1) update=yes updatewhereclause=yes name=dup_tag dbname="etlcoil.dup_tag" initial="0" )
 column=(type=char(1) update=yes updatewhereclause=yes name=op_tag dbname="etlcoil.op_tag" initial="T" )
 column=(type=char(1) update=yes updatewhereclause=yes name=post_tag dbname="etlcoil.post_tag" )
 column=(type=char(40) update=yes updatewhereclause=yes name=defect dbname="etlcoil.defect" )
 column=(type=char(25) update=yes updatewhereclause=yes name=location dbname="etlcoil.location" )
 column=(type=char(1) update=yes updatewhereclause=yes name=mp dbname="" initial="N" values="Y      Y/N      N/" )
 column=(type=decimal(3) update=yes updatewhereclause=yes name=thick_to dbname="etlcoil.thick_to" initial="0" )
 column=(type=char(15) update=yes updatewhereclause=yes name=slit_id dbname="etlcoil.slit_id" )
 column=(type=char(15) update=yes updatewhereclause=yes name=lc_no dbname="etlcoil.lc_no" )
 column=(type=char(2) update=yes updatewhereclause=yes name=section_code dbname="etlcoil.section_code" )
 retrieve="  SELECT etlcoil.trans_id,  
         etlcoil.location,  ,  
    FROM etlcoil  
   WHERE ( ~"etlcoil~".~"trans_id~" = :ra_trans_no )  
     and ( op_tag = 'T' )  
" update="etlcoil" updatewhere=2 updatekeyinplace=yes arguments=(("ra_trans_no", string))  sort="etl_coil_id A " )
text(band=header alignment="2" text="Slit

I want to delete columns slit_id,lc_no,dup_tag,stpl_tag_no at runtime.
I don't want to change datawindow style that is processing=0 should not be changed.
How to do it.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

issue a destroy command
  dw_1.modify ("destroy slit_id")
  dw_1.modify ("destroy lc_no")
or you could do a SyntaxFromSQL( check in the help) and select only the fields that you want.
you can also use the destroy statement in a single line
  dw_1.modify ("destroy slit_id destroy ic_no")
just keep on adding the columns
MateenAuthor Commented:
Hi sajuks

I wrote dw_1.modify ("destroy slit_id") in constructor event.

The column deleted but the heading above remains and there and the form did not adjust accordingly.

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

You need to delete the header text in the same way, Also to adjust the width is another pain.
i'd recommend using the SyntaxFromSQL function.Check in the help file for a detailed answer/
MateenAuthor Commented:
If I use syntaxfromsql() and remove unwanted columns, then, will the form  be adjusted accordingly.
Will it also delete the related headings(text just above the column).
did you check the example in the help file. You are recreating the existing dataobject by including only the fields you need.
Since your whole select is changing then the gaps wont be there would it ?
If you frequently use this window then wouldnt it be better to create a copy of the existing dataobejct ( excluding the undesired fields ) ?
There is one more way that you could do this, thats by setting the visible property to false based on some condition in the dataobejct itself.There you could then mark the fields to slide left so taht the gaps are filled up.But  i really would suggest creating another dataobject or recreating the sql as the above cant be guaranteed to slide perfectly on all machines.(i used to 've this problem on one machine,windows xp might've been something else but was never able to figure it out )

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MateenAuthor Commented:
Ok, sajuks.
I would sort it out and let u know.


"I wrote dw_1.modify ("destroy slit_id") in constructor event.
The column deleted but the heading above remains and there and the form did not adjust accordingly."

You will also need to delete the column header object explicitly
dw_1.modify ("destroy slit_id_t")

Also, you need to move the objects explicitly.. So overall sajuks suggestion of having two DWs looks good.
If it was grid style, everything would have been ok..

Vikas Dixit
MateenAuthor Commented:
Hi vikas:

I just asked the question if it could be done for tabular DW. I would try to sort it out first by
using syntaxfroxsql and if not succeeded then by changing tabular to grid. Can I, in grid dw, copy and paste column and
rename the pasted column and associate drop down datawindow the same way as in tabular Dw. (I have not tried yet).

Now the following commen is made in most humble manner. (Please ignore it If I am not good).
Actually, there are four users, for them basics are same, and a few columns are needed by one and not by another.
If I make more than one DW and if any change/refinements is made on basics then I will have to do the same on all dws.


You could try using the hide show ( visisble) property of the datawindow.
Place once column above the another. If user1 views then show column A else show column B.
Grid datawindow wpuld be able to do change the ddw but dont think that copy and paste column will work. havent tried it.
Not sure what Copy and Paste Column means.. Never tried that... But associating DDDW will surly work..

Sajuks option of hide/show is good if you have mutually exclusive columns to show(for user 1 show A, for user 2 show B).

Another option may be to change the position of colums that are not basic, at end, so that you can Just Delete them, But not sure if it will acceptable to the users.

If it's a single DW, then you have to move the Colum ( and their header positions) explicitly. You can do it in script, instead of doing in the Syntax. This algorithm may be of some help( not PB code)

A B C D E F G H I ( Column list)
A C D E G I  ( colums B, F , H deleted):

//Before destroying the columns, Correct positions of other columns.
integer li_shift =0// How much each col to shift.
for column in A to I
  column.x= column.x - li_shift
  if column to be destroyed then  li_shift = li_shift + column.width (and + space between the columns, if any)

//Now procees to destroy the columns.

Vikas Dixit

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.