Page 1 of 1

datagrid updating a row

Posted: Fri May 29, 2015 11:44 pm
by jalz
Hi Guys,

Need some advice. I've got a datagrid (table) called dg_charge_rate and I'd like to update a specific row. Previously the way handled it was by deleting the row and then adding a new row with the old ID. The drawback of this method was that the new item would be added to the end of the row. I've been reading up on the datagrid api and I think SetDataOfLine should allow me to update the row. I've included my code below, anyone point me where I'm going wrong with that particular line?

Cheers
Jalz


Code: Select all


put fld "fld_charge_description" into theDataA["charge_description"]
   put fld "fld_charge_rate" into theDataA["charge_rate"]
   put the label of btn "cb_chargeable" into theDataA["chargeable"]
   put fld "fld_charge_rate_lineno" into theDataA["chargeID"]
   
   put fld "fld_charge_rate_lineno" into tLineNo
   
   if tLineNo is an integer then
      --send "DeleteLine tLineNo" to group "dg_charge_rates"
      dispatch SetDataOfLine to grp "dg_charge_rates" with  tLineNo, theDataA
   else
      dispatch "AddData" to group "dg_charge_rates" with theDataA
   end if
   
   -- refresh the datagrid
   dispatch "RefreshIndex" to group "dg_charge_rates" with the dgHilitedIndex of group "dg_charge_rates"
   


Re: datagrid updating a row

Posted: Sat May 30, 2015 8:35 am
by bangkok
I've added an "update" part to my DG examples stack.

2 methods are described : dgIndex and dgDataOfIndex.

Might help.

Re: datagrid updating a row

Posted: Sat May 30, 2015 5:40 pm
by sritcp
jalz wrote:

Code: Select all

.....................
      dispatch SetDataOfLine to grp "dg_charge_rates" with  tLineNo, theDataA
   ................................
Try adding quotes to the command:
dispatch "SetDataOfLine" to ....

Regards,
Sri.

Re: datagrid updating a row

Posted: Sat May 30, 2015 9:12 pm
by jalz
Thanks Guys,

@sritcp putting quotes around the command didn't work. However, that sample file you posted bangkok was excellent - it showed me how to deal with and manipulate data in the datagrid.

Jalz