-1

can any one please help me how to know which button is click on data-window& what is the button clicked row number. I have created a data window which fetch the emp data from the table. I have added two button on data-window one is update & second is delete.

data window looks like:-

A B C [del][update]

q w e [del][update]

r t y [del][update]

& is two button data-window

I want as user click on del button row will deleted from dw as well as table. & as click on update button data will be update on Dw as well as in table.

thanks

rahul jain
  • 143
  • 1
  • 3
  • 12
  • I got the method ls_Object = String(dwo.name) which return the button name. but problem is that not able to get row num. if user select the row 1 & click on row 3 button actionreturncode return 1 not 3. – rahul jain May 08 '14 at 13:12
  • "row" is a parameter to the ButtonClicked event. Are you having problems with that data? – Terry May 08 '14 at 14:18

1 Answers1

0

sorry for not replying to your mail. I was at heavy work load. I have read your question . solution as follows.
First you dont need to have two buttons on each row. Just put two buttons on window. In your slang its form.
Then name it as cb_update and cb_delete
Then i think you have retrieved the data from the database to powerbuilder datawindow. Whats your datawindow name ? , here i assuming your datawindow name as dw_emp.

Go to instance variable place and declare an instance long variable <>

Long ll_rownumber

Double click that datawindow . in that select the clicked event . in that there are predefined variables available we can use that. just follow my code. you will understand later

datawindow clicked event
ll_rownumber=row
this.selectrow(0,false)
this.selectrow(row,true)

Now write the code on cb_delete button
dw_emp.DeleteRow(ll_rownumber)

Next write down the code on cb_update button
dw_emp.Update()
dw_emp.reset()
dw_emp.retrieve()


For update your datawindow's update properties must be set. to do this. open that window. right click on the datawindow in that select Modify Datawindow. now look for menu Rows . In that select submenu update properties.
Select Allow update check box. Then select all columns in updatable columns . Then select the unique key column on the right side. at last on top select the table name. Then ok.
now run the code. To delete you should click on the particular row. and then select delete button. and then select update button.

regards
Raj

  • Thanks for your reply.. i am done with the delete part.. ls_Object = String(dwo.name) If ls_Object = "b_ddelete" Then dw_1.DeleteRow(l) rtn = dw_1.Update() IF rtn = 1 THEN COMMIT USING SQLCA; messagebox("","delete row "+ string(l)); ELSE ROLLBACK USING SQLCA; END IF is there any way to update the particular row on which user click on button. i have tried to found solution. but not getting any method to update selected row – rahul jain May 08 '14 at 15:19
  • Actullay u need not to worry about updating the particular row. Because in powerbuilder datawindow the which you have modified that ony gets updated. other rows are not updated. So when u call the dw.update() it will check for the modified count and updates the particular row. to check this in datawindow look for the event sqlpreview in that put the following messagebox. Messagebox('',sqlsyntax). Then run your application. modify the single row and do update you will see the update statement. - –  May 09 '14 at 07:17
  • If you get the answer then vote up for it. Then it will be displayed on top when others searching for same one.@rahuljain –  May 09 '14 at 14:16