datagrid: rows disapear when add new row

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

datagrid: rows disapear when add new row

JosepM
Hi,

I detected a strange issue with the datagrid.

When add a row that is out of the visibles rows and modify data and add a new row all the data disapear, still into the datagrid but isn't showed... if I add a new row I can see flashing the data but disapear.

Any idea?

Salut,
Josep
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

JosepM
Hi,

I'm watching than the first time that the row is created and is beyond the rows that can be displayed the scrollbar doesn't scroll automatically to the new row, and when you edit some value in this row cause

a) the first time that the value is edit isn't filled, so you need edit again to put the value.
b) if you add a new row all the datagrid disappear. Still remaining into the datagrid but isn't showed.


Salut,
Josep
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

JosepM
Hi,

This happen with "addLine" command, with "addData" the effect is that the last row is duplicated into the first row... :(

Any help or idea...

Salut,
Josep
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

Trevor DeVore
In reply to this post by JosepM
On Tue, Feb 1, 2011 at 8:29 AM, JosepM <[hidden email]> wrote:

>
>  When add a row that is out of the visibles rows and modify data and add a
> new row all the data disapear, still into the datagrid but isn't showed...
> if I add a new row I can see flashing the data but disapear.


Can you post the code you are using?

--

Trevor DeVore

Blue Mango Learning Systems

ScreenSteps: http://www.screensteps.com

LiveCode Resources for Developers: http://livecode.bluemangolearning.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

JosepM
The filldata

on FillInData pData
   Global gRecargo
   Global gTaxes
   
   put glxapp_getPref ("decimals_price") into tDecimals_Price
   put glxapp_getPref ("decimals_unit") into tDecimals_Unit
   
   try
      set the numberFormat to tDecimals_Price -- dollar format
     
      -- This message is sent when the Data Grid needs to populate
      -- this template with the column data. pData is the value to be displayed.
      set the text of me to pData
      --set the unicodetext of me to uniencode(pData,"utf8")
      SetForegroundColor
     
      switch the dgColumn of me
         case "NAME"
            --find fld f_buscar
            --truncatetail the short id of me, "..."
            set the dontwrap of me to false
            break
           
         case "UNITS"
            if isnumber(pData) then
               
               put GetDataOfIndex (the dgIndex of me, "PRICE") into tPrecioCoste
               put GetDataOfIndex (the dgIndex of me, "UNITS") into tUnidades
               put GetDataOfIndex (the dgIndex of me, "REDUCTION_PERCENT_1") into tDto1
               put GetDataOfIndex (the dgIndex of me, "REDUCTION_PERCENT_2") into tDto2
               
               replace comma with "." in tPrecioCoste
               replace comma with "." in tUnidades
               
               replace comma with "." in tDto1
               replace comma with "." in tDto2
               
               put tUnidades * tPrecioCoste into tTotal
               put tDto1 / 100 into tDto1
               put tTotal * tDto1 into tDtoTotal
               put tTotal - tDtoTotal into tTotal
               --replace "." with comma in tTotal
               
               SetDataOfIndex the dgIndex of me, "AMOUNT_LINE", tTotal --& " €"
               
            end if    
            break
           
      end switch
     
   [... calculations ...]  
     
   catch e
      answer e
   end try
   
end FillInData

The CloseFieldEditor

on CloseFieldEditor pFieldEditor
   Global gTaxes
   Global tCliente
   Global gDocType
   
   
   put glxapp_getPref ("decimals_price") into tDecimals_Price
   put glxapp_getPref ("decimals_unit") into tDecimals_Unit
   
   --set the numberFormat to tDecimals_Price  --"#.00" -- euro format
   
   ## save the data to dgData array before upating aggregate fields
   switch the dgColumn of me
      case "CODE"
         put the text of pFieldEditor into tCode
         --answer tCode
         put _GetProduct (tCode) into tArrayA
         printkeys tArrayA
         
         ## Begin Control numeros de serie
         --answer tArrayA["NEEDSSERIALNUMBER"]
         --if tArrayA["NEEDSSERIALNUMBER"] is not empty then
         --answer "Capturar numero serie" as sheet
         --else
         --answer "Else" as sheet
         --end if
         ## End Control numeros de serie
         
         if gDocType is 8 or gDocType is 9 then
           
            ## Aplicar precio compra producto
            if  isnumber(tArrayA[1]["PRICE_WHOLESALE"]) then
               set the numberFormat to tDecimals_Price
               replace "," with "." in tArrayA[1]["PRICE_WHOLESALE"]
               put tArrayA[1]["PRICE_WHOLESALE"] into tPrice
               if tPrice is not empty then
                  put tArrayA[1]["PRICE"] into tPrecioTarifa
                  multiply tPrecioTarifa by 1
               end if
            else
               put 0 into tPrecioTarifa
            end if
         else
            ## Aplicar precio venta producto
            ## Aplicar precio tarifa por cliente
            put DESC & tCliente["CLI_ID_PRICELIST"] into tTarifa        
           
            if  isnumber(tArrayA[1]["PRICE"]) then
               set the numberFormat to tDecimals_Price
               replace "," with "." in tArrayA[1]["PRICE"]
               put tArrayA[1]["PRICE"] into tPrice
               if tPrice is not empty then
                  replace "," with "." in tArrayA[1][tTarifa]
                  put tArrayA[1][tTarifa] into tPercent
                  if tPrecent is not 0 then
                     multiply tPrice by tPercent
                     divide tPrice by 100
                     put tArrayA[1]["PRICE"]-tPrice into tPrecioTarifa
                     multiply tPrecioTarifa by 1
                  else
                     put tArrayA[1]["PRICE"] into tPrecioTarifa
                     multiply tPrecioTarifa by 1
                  end if
               end if
            else
               put 0 into tPrecioTarifa
            end if
         end if
         
         if gDocType is 8 or gDocType is 9 then
            ## Poner valores en la datagrid
            SetDataOfIndex the dgIndex of me, "NAME", "(" & tArrayA[1]["SUPPLIER_REFERENCE"] & ") " & tArrayA[1]["NAME"]
         else
            ## Poner valores en la datagrid
            SetDataOfIndex the dgIndex of me, "NAME", tArrayA[1]["NAME"]
         end if
         SetDataOfIndex the dgIndex of me, "PRICE", tPrecioTarifa
         
         put gTaxes[tArrayA[1]["ID_TAX"]]["VALOR"] into tValorIVA
         SetDataOfIndex the dgIndex of me, "ID_TAX", tValorIVA
         
         set the text of pFieldEditor to tCode
         
         break
      case "UNITS"
         set the numberFormat to tDecimals_Unit
         put the text of pFieldEditor into tValue
         replace "," with "." in tValue
         set the text of pFieldEditor to tValue+0
         break
      case "PRICE"
         set the numberFormat to tDecimals_Price -- dollar format
         put the text of pFieldEditor into tValue
         replace "," with "." in tValue
         set the text of pFieldEditor to tValue+0
         break
      case "REDUCTION_PERCENT_1"
         put the text of pFieldEditor into tValue
         replace "," with "." in tValue
         set the text of pFieldEditor to tValue+0
         break
      case "DAYS"
         set the numberFormat to tDecimals_Unit
         put the text of pFieldEditor into tValue
         replace "," with "." in tValue
         set the text of pFieldEditor to tValue+0
         break
      case "DIMENSION3"
         set the numberFormat to tDecimals_Unit
         put the text of pFieldEditor into tValue
         replace "," with "." in tValue
         set the text of pFieldEditor to tValue+0
         break
      case "DIMENSION4"
         set the numberFormat to tDecimals_Unit
         put the text of pFieldEditor into tValue
         replace "," with "." in tValue
         set the text of pFieldEditor to tValue+0
         break
      case "ADUANA"
         set the numberFormat to tDecimals_Price
         put the text of pFieldEditor into tValue
         replace "," with "." in tValue
         set the text of pFieldEditor to tValue+0
         break
      default
         put the text of pFieldEditor into tValue
         break
   end switch
   
   SetDataOfIndex the dgIndex of me, the dgColumn of me, the text of pFieldEditor
   
 
end CloseFieldEditor

The editValue

command EditValue
   --set the dgTemplateFieldEditor["utf8text"] of the dgControl of me to unidecode(the unicodetext of me,"utf8")
   -- word 1 to -2 because of 0001 that is added to control name
   switch the dgColumn of me
      ## allow editing for these columns only.
      case "CODE"
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         --EditFieldText the long id of me, the dgIndex of me, word 1 to -2 of the short name of me
         break
      case "NAME"
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         --EditFieldText the long id of me, the dgIndex of me, word 1 to -2 of the short name of me
         break
      case "UNITS"
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         --EditFieldText the long id of me, the dgIndex of me, word 1 to -2 of the short name of me
         break
      case "PRICE"
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         --EditFieldText the long id of me, the dgIndex of me, word 1 to -2 of the short name of me
         break
      case "REDUCTION_PERCENT_1"
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         --EditFieldText the long id of me, the dgIndex of me, word 1 to -2 of the short name of me
         break
      case "REDUCTION_PERCENT_2"
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         --EditFieldText the long id of me, the dgIndex of me, word 1 to -2 of the short name of me
         break
      case "ID_TAX"
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         EditFieldText the long id of me, the dgIndex of me, the dgColumn of me
         --EditFieldText the long id of me, the dgIndex of me, word 1 to -2 of the short name of me
         break
   end switch
   
end EditValue
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

Trevor DeVore
On Tue, Feb 1, 2011 at 3:25 PM, JosepM <[hidden email]> wrote:

>
> The filldata
> ...


I don't see any code here that adds rows to the data grid. Where is that
code?

--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
LiveCode Resources for Developers: http://livecode.bluemangolearning.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

JosepM
Sorry...

on mouseup
 
   put the dgNumberOfLines of group "dg_test" of this stack into tFilas
   
   if tFilas<9 then
      put "00" & tFilas+1 into tLinea
   else
      put "0" & tFilas+1 into tLinea
   end if
   
   dispatch "addLine" to group "dg_test" of this stack with tLinea
   
   dispatch "ResetList" to group "dg_test" of this stack
   
end mouseup

Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

Trevor DeVore
On Tue, Feb 1, 2011 at 3:57 PM, JosepM <[hidden email]> wrote:

>
>  on mouseup
>     put the dgNumberOfLines of group "dg_test" of this stack into tFilas
>
>   if tFilas<9 then
>      put "00" & tFilas+1 into tLinea
>   else
>      put "0" & tFilas+1 into tLinea
>   end if
>
>   dispatch "addLine" to group "dg_test" of this stack with tLinea
>
>   dispatch "ResetList" to group "dg_test" of this stack
> end mouseup


I assume this button resides outside of the data grid. So clicking on this
button causes a line to be added and the bug you are seeing to occur?

--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
LiveCode Resources for Developers: http://livecode.bluemangolearning.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

Trevor DeVore
In reply to this post by JosepM
On Tue, Feb 1, 2011 at 3:25 PM, JosepM <[hidden email]> wrote:

>
> The CloseFieldEditor
>
> on CloseFieldEditor pFieldEditor
>   Global gTaxes
>   Global tCliente
>   Global gDocType
>
> ...
>
> end CloseFieldEditor
>

Have you tried adding a try/catch block to the CloseFieldEditor code to see
if some sort of error is occurring?

Also, why are you calling ResetList? AddLine should refresh the data grid
for you automatically.

--

Trevor DeVore

Blue Mango Learning Systems

ScreenSteps: http://www.screensteps.com

LiveCode Resources for Developers: http://livecode.bluemangolearning.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

JosepM
I don't remember why I use ResetList but sometimes doesn't refresh correctly.

The bug success when you scroll down to edit the row that is out of the viewable area. But only the first time, if you add many rows and scroll down and edit, nothing happen.

This happen with a fresh datagrid.

1) create a datagrid with 6 rows and 4 cols visibles. Left the properties by default.
2) add 5 rows and edit the col 2 and col 3. Tab from col 3 to col 4.
3) add the 6th row and edit col 2 and col 3 and press tab until col 4. The value filled into col 3 isn't showed.
4) add the 7th row and scroll and edit. The scroll isn't showed auto, you must scroll down.
5) if you add another row, all data flash and disappear. The data still here but isn't showed.


Salut,
Josep
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

JosepM
I put try-catch into each message and no error found, but the effect is the same. Is when edit the new row that isn't showed, after this the data presentation crash.

UPDATE:
If you instead of add one row (when the next row is out of viewable area) add two, the effect doesn't happen.

Salut,
Josep
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

Trevor DeVore
In reply to this post by JosepM
On Tue, Feb 1, 2011 at 6:27 PM, JosepM <[hidden email]> wrote:

>
> I don't remember why I use ResetList but sometimes doesn't refresh
> correctly.
>
> The bug success when you scroll down to edit the row that is out of the
> viewable area. But only the first time, if you add many rows and scroll
> down
> and edit, nothing happen.
>
> This happen with a fresh datagrid.
>
> 1) create a datagrid with 6 rows and 4 cols visibles. Left the properties
> by
> default.
> 2) add 5 rows and edit the col 2 and col 3. Tab from col 3 to col 4.
> 3) add the 6th row and edit col 2 and col 3 and press tab until col 4. The
> value filled into col 3 isn't showed.
> 4) add the 7th row and scroll and edit. The scroll isn't showed auto, you
> must scroll down.
> 5) if you add another row, all data flash and disappear. The data still
> here
> but isn't showed.
>

I created the data grid as specified above and used your mouseUp
script. This code worked fine in my tests. What version of LiveCode are you
using and what do you get if you execute the following in the message box:

put the uRIP["version"]  of stack "revDataGridLibrary" && the
uRIP["buildnumber"] of stack "revDataGridLibrary"

--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
LiveCode Resources for Developers: http://livecode.bluemangolearning.com
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: datagrid: rows disapear when add new row

JosepM
I get 1.0.2 11

I try with 4.5.3 and 4.6 and the same.



Salut,
Josep