Undefined datagrid customformat column

Martin Obongita martin.obongita at yahoo.com
Wed Oct 30 20:06:30 UTC 2024


 Hi Michael,
I have removed that line of iTotal. Now the undefined error has gone. A new error has been returned on event after. The column cell now displays "null" when I tab out of the cell.

Regards,Martin.


    On Wednesday, October 30, 2024 at 09:42:25 PM GMT+3, Michael Monschau <michael at brainydata.co.uk> wrote:  
 
 
Hi Martin,

First: yes this is quite possible which would explain the ‘undefined’ as this is a common javascript error, assuming that this is how the datagrid communicates errors in the $formatcell method. As I said, I never used it. One way to confirm is to 


Looking at the code in stages:

> Calculate lValue as iList.[pRow].[pCol]

should be no problem as that is generic regardless of list definition

> If pCol<>1
> 
> Calculate lValue as jst(lValue,'n2')
> 
> End If
This would not cause an undefined error, but may be applying the incorrect formatting if the columns other than column 1 are not numbers

> If iList.[pRow].iTotal<0

This could cause an undefined error if iTotal is no longer a column in the list. I suspect your SQL definition does not include a column called ‘iTotal’
in which case my money is on this line

The rest seems unlikely to generate an undefined error

Second: This should not be the problem other than that your SQL definition does not have a column called iTotal.
Also, as I said, if you rely on iList still being a proper table class throughout, it will become destroyed when list data changes on the client and the list is sent back to the server as the server copy will be overwritten by the client copy. iList will still have the column definition but will loose its connection to the table instance. I recommend letting your remote task own the list via a task variable and make the remote form take a copy of it as an instance variable. You then need to send cell changes to a server method that can apply the changes to your task variable.

Hope this helps

Regards,
Michael

Brainy Data Limited
The Home for Omnis components
Web: www.brainydata.com
GitHub: https://github.com/BrainyData


> On 30 Oct 2024, at 16:23, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
> 
> Hi Michael,
> First,The datagrid object has this formatcell client method:
> Calculate lValue as iList.[pRow].[pCol]
> 
> If pCol<>1
> 
> Calculate lValue as jst(lValue,'n2')
> 
> End If
> 
> 
> # note, client executed method requires color parameter to be a string unless using a constant. Can alternativley be a HTML color string eg. '#FF0000'
> 
> If iList.[pRow].iTotal<0
> 
> # Calculate iHtml as styledtohtml(con(style(kEscColor,'#FF0000'),style(kEscStyle,kBold),lValue))
> 
> Calculate iHtml as styledtohtml(con(style(kEscColor,'rgba(255,0,0,1)'),style(kEscStyle,kBold),lValue))
> 
> Else
> 
> Calculate iHtml as styledtohtml(con(style(kEscColor,kDarkGreen),style(kEscStyle,kItalic),lValue))
> 
> End If
> Quit method iHtml
> 
> 
> Second,
> 
> Do iList.$define(iMonth,iMoneyIn,iMoneyOut,iTotal)
> 
> versus,
> 
> 
> 
> Do iList.$definefromsqlclass($tables.person)
> 
> 
> 
> 
> Could any of these cause issues with the display in a datagrid?I hope the formatting of text comes through with correct paragraphs.
> 
> Regards,Martin.
> 
> 
> 
> 
>    On Wednesday, October 30, 2024 at 07:01:15 PM GMT+3, Michael Monschau <michael at brainydata.co.uk> wrote:  
> 
> Hi Martin,
> 
> I apologise, I misunderstood and went on a tangent where my memory went down the complex grid route, somewhat different (busy getting ready for EurOmnis). I must admit I never looked at the jsDataGrid sample library, but I do use the datagrid in my presentation, both js-client and desktop.
> 
> Firstly: I am not sure what you mean when you say "change the list definition from instance variables and instead define it from a sql table”. The list (defined from a table or otherwise) must be an instance variable or the client doesn’t see it.
> 
> Secondly: If I set $dataname to a SQL list and turn on $userdefined, I set as a minimum $columnname and $columndatacol for each column I intend to display. That works for me. When I do that I can edit data no problem.
> 
> The scenario you are describing I have not come across and I don’t know what could be causing it. Have the columns additional formatting set which may not be compatible with the data from your SQL list?
> 
> One thought I had: Because my SQL lists are also obviously smartlists (otherwise you could not use $dowork and related), smart-lists do not work on the client. All the smart stuff is lost when sent to the client. Consequently when the data in a column is changed and the list is sent back to the server your list will now be an ordinary list. This is in fact a subject I will be talking about in my JSON control sessions. What I do is, I make a copy of the SQL list which is a task var and the copy is an instance var. I then ensure that when data in a cell is changed I send a message to the server and apply this change to the SQL list. 
> 
> Perhaps this is where it is going wrong for you. I hope I have put it well enough so it makes sense.
> 
> Kind regards,
> Michael
> 
> 
> Brainy Data Limited
> The Home for Omnis components
> Web: www.brainydata.com
> GitHub: https://github.com/BrainyData
> 
> 
> 
>> On 29 Oct 2024, at 10:35, Michael Monschau <michael at brainydata.co.uk> wrote:
>> 
>> Hi Martin,
>> 
>> I will actually be demoing this very scenario at EurOmnis, although I am not using custom-formatting with the datagrid!
>> 
>> I would suspect you need to change the custom format definitions from <instance_var_name> to <list_name.instance_var_name>.
>> 
>> Regards,
>> Michael
>> 
>> 
>> sent from my iPad
>> 
>>> On 29 Oct 2024, at 09:19, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
>>> 
>>> 
>>> Dear All,
>>> 
>>> I’m working on the sample library jsDataGrid Formatting. I noticed that if I change the list definition from instance variables and instead define it from a sql table class, the data entered into the datagrid columns change to “undefined”. If I tab out of the column entry and back again into the entry column, the previous data entered is visible. If I tab out the entry cell it changes to “undefined”. What could be causing this?
>>> 
>>> The datagrid object is in a js remote form.
>>> 
>>> Regards
>>> 
>>> Martin O.
>>> 
>>> _____________________________________________________________
>>> Manage your list subscriptions at https://lists.omnis-dev.com
>>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 

_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com
Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
  


More information about the omnisdev-en mailing list