Deleting column at runtime of a tabular datawindow.

Posted on 2004-12-01
Last Modified: 2013-12-26
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.
Question by:Mateen
    LVL 33

    Expert Comment

    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.
    LVL 33

    Expert Comment

    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

    Author Comment

    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.

    LVL 33

    Expert Comment

    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/

    Author Comment

    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).
    LVL 33

    Accepted Solution

    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 )

    Author Comment

    Ok, sajuks.
    I would sort it out and let u know.

    LVL 8

    Expert Comment


    "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

    Author Comment

    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.


    LVL 33

    Expert Comment

    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.
    LVL 8

    Assisted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now