Goofy question about Datagrids

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

Goofy question about Datagrids

Richmond Mathewson-2
What advantage has a datagrid over a tableField?

I would be very grateful indeed for a properly formulated
explanation.

Richmond.

_______________________________________________
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: Goofy question about Datagrids

Roger Eller
Hi Richmond,

I'll give you an 'improperly formulated' explanation of my own experience
with datagrids.  They are more complicated to use (at first).  So most of
the time I still use a table field for everything except where the nice
appearance of a datagrid gives the design a polished and professional
look.  The alternating row color is pleasing to the eye, and practical for
viewing 'wide' data.  Functionally, a datagrid is easier to rearrange
column order than a roll-your-own table script.  I'm sure there are
datagrid advocates, but I still like the simplicity of the table field for
most things.

~Roger


On Tue, Nov 1, 2016 at 2:29 PM, Richmond <[hidden email]>
wrote:

> What advantage has a datagrid over a tableField?
>
> I would be very grateful indeed for a properly formulated
> explanation.
>
> Richmond.
>
>
_______________________________________________
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: Goofy question about Datagrids

Peter TB Brett
In reply to this post by Richmond Mathewson-2
On 01/11/2016 18:29, Richmond wrote:
> What advantage has a datagrid over a tableField?

You can build each row of datagrid using any controls or widgets.

                                 Peter

--
Dr Peter Brett <[hidden email]>
LiveCode Technical Project Manager

lcb-mode for Emacs: https://github.com/peter-b/lcb-mode

_______________________________________________
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: Goofy question about Datagrids

Mike Kerner
N00bs should also check out modTableField and tableLab (Bernd and Scott,
respectively)
http://berndniggemann.on-rev.com/modTableField/modTableField_0_1_9.livecode.zip
http://forums.livecode.com/download/file.php?id=5458&sid=672cdd04a95bc2c80430bc1bc88b7470

On Tue, Nov 1, 2016 at 3:15 PM, Peter TB Brett <[hidden email]>
wrote:

> On 01/11/2016 18:29, Richmond wrote:
>
>> What advantage has a datagrid over a tableField?
>>
>
> You can build each row of datagrid using any controls or widgets.
>
>                                 Peter
>
> --
> Dr Peter Brett <[hidden email]>
> LiveCode Technical Project Manager
>
> lcb-mode for Emacs: https://github.com/peter-b/lcb-mode
>
>
> _______________________________________________
> 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
>



--
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
_______________________________________________
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: Goofy question about Datagrids

Richmond Mathewson-2
In reply to this post by Peter TB Brett
Possibly . . .

But what I really meant was "what advantage does a datagrid have over a
tableField vis-a-vis
spreadsheet handling?"

Sorry; finding it rather difficult to formulate an uneasy feeling I've
had about datagrids ever
since they were first introduced.

Richmond.

On 1.11.2016 21:15, Peter TB Brett wrote:
> On 01/11/2016 18:29, Richmond wrote:
>> What advantage has a datagrid over a tableField?
>
> You can build each row of datagrid using any controls or widgets.
>
>                                 Peter
>


_______________________________________________
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: Goofy question about Datagrids

dunbarxx
This post was updated on .
Richmond.

Very little, in the narrow sense that you ask the question. They are both tab and return delimited data gadgets. In a table field, like any field, you just put in formatted text. In a DG, you set the dgText (or dgData).

At the very lowest level of increased functionality, or at least display nicety, DG's automatically display alternate row colors. I had to script this for a table field long ago, with scrolling, before I got my feet wet with DG's.

And I think you know just a little about how much farther you can go with a DG if you want to get fancy. Table fields are pretty much WYSIWYG.

Craig
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

BNig
In reply to this post by Mike Kerner

For modTableField I recommend version 0.3.2

http://berndniggemann.on-rev.com/modTableField/modTableField_0_3_2.zip

Kind regards
Bernd
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

jameshale
In reply to this post by Richmond Mathewson-2
Interestingly I actually wasn't aware of LC's table field when I was working on the interface of my current app. Given all my previous work with LC was really about utilities that acted on something external and produced something external to the stack. Indeed I rarely made standalones being quite happy to use my tools while in the IDE.
When I did think of the table field I saw it as nothing more than a way to display tab delimited text.

Where I have needed to use a table "like" field I have also wanted to have something more than just text involved.
For example, a checkbox or a radio button. An image or some other control associated with a line of the table.

The data grid makes this really quite easy, once you get your head around it.

It is really useful to go through the examples in the Data Grid guide (the one included with LC 8.1+, not the one on the LC web site) and just follow along. The examples should all work as they had to be tested in order to create the images to match LC8+'s IDE. It is really worthwhile and doing them, rather than just reading through them takes a lot of the mystery out of the Data Grid and makes you appreciate what a phenomenal job Trevor did in creating it.
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Bob Sneidar-2
In reply to this post by Richmond Mathewson-2
It's my impression that Datagrids make terrible spreadsheets as is. But so does the table field. A LOT of work has to be done on both to get them to act like a spreadsheet. As it turns out, a spreadsheet is a quite complicated thing to implement. If you intend to do calculations, then there is a whole layer of vast complexity unto itself. Relative vs. absolute references? Mixed references? What happens when you insert a cell, row or column? Can you paste data in? How will it format?

I can't believe you are shooting for all this complexity, but rather are only trying to create a way to display, and perhaps manipulate tabular data. In that case, I'd go with the table field.

Bob S


> On Nov 1, 2016, at 12:29 , Richmond <[hidden email]> wrote:
>
> Possibly . . .
>
> But what I really meant was "what advantage does a datagrid have over a tableField vis-a-vis
> spreadsheet handling?"
>
> Sorry; finding it rather difficult to formulate an uneasy feeling I've had about datagrids ever
> since they were first introduced.
>
> Richmond.
>


_______________________________________________
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: Goofy question about Datagrids

Roger Eller
If you want to total a column in a simple table field, assuming column 8,
this is my long-winded approach.

on mouseUp
   set the itemDel to TAB
   constant tColumn = 8
   constant tFieldName = "myFakeSpreadsheet"
   put the number of lines of fld tFieldName into tLineCount
   if line -1 of fld tFieldName contains "TOTALS:" then
      delete line -1 of fld tFieldName
      put cr & "TOTALS:" after fld tFieldName
   else
      put cr & "TOTALS:" after fld tFieldName
   end if
   repeat for each line thisLine in fld tFieldName
      put item tColumn of thisLine & comma after tListOfNumbers
   end repeat
   put sum(tListOfNumbers) into tTotal
   put tTotal into item tColumn of line -1 of fld tFieldName
end mouseUp

~Roger


On Wed, Nov 2, 2016 at 11:31 AM, Bob Sneidar <[hidden email]>
wrote:

> It's my impression that Datagrids make terrible spreadsheets as is. But so
> does the table field. A LOT of work has to be done on both to get them to
> act like a spreadsheet. As it turns out, a spreadsheet is a quite
> complicated thing to implement. If you intend to do calculations, then
> there is a whole layer of vast complexity unto itself. Relative vs.
> absolute references? Mixed references? What happens when you insert a cell,
> row or column? Can you paste data in? How will it format?
>
> I can't believe you are shooting for all this complexity, but rather are
> only trying to create a way to display, and perhaps manipulate tabular
> data. In that case, I'd go with the table field.
>
> Bob S
>
>
> > On Nov 1, 2016, at 12:29 , Richmond <[hidden email]> wrote:
> >
> > Possibly . . .
> >
> > But what I really meant was "what advantage does a datagrid have over a
> tableField vis-a-vis
> > spreadsheet handling?"
> >
> > Sorry; finding it rather difficult to formulate an uneasy feeling I've
> had about datagrids ever
> > since they were first introduced.
> >
> > Richmond.
> >
>
>
> _______________________________________________
> 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
>
_______________________________________________
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
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Sri
In reply to this post by Richmond Mathewson-2
1. The underlying data structure is in the form of an array (dgData). So, anytime there is frequent access to edit, calculate, and re-display results, array will have an edge over list. This would be even better if LC introduced additional array manipulation commands such as (multidimensional) matrix multiplication, etc.

2. Individual columns can be populated using their own rules (FillinData). Thus, it is possible, say, to color a row green if the email column of the row data contains "richmond"

3. Since you can have buttons, checkboxes, images, graphics, etc., in a cell (not just text), you can have different tools show up in a cell (column-row) depending on the value of an entry in a different cell in that row.

4. All this with DG table. DG form can do much more, but is not comparable to a spreadsheet and so is not relevant to your query.

Regards,
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Bob Sneidar-2
This is something I want to look into. I store datetime data in "international" format, but I want to display it in a kind of short date/time format. Currently I run the datagrid array through some functions for doing that, but it might be advantageous to have the datagrid library do this for me. Trick is, I need to reconvert it going back out, so I would need to display a value one way while leaving the underlying format as is.

Bob S


On Nov 2, 2016, at 10:21 , Sri <[hidden email]<mailto:[hidden email]>> wrote:

2. Individual columns can be populated using their own rules (FillinData).
Thus, it is possible, say, to color a row green if the email column of the
row data contains "richmond"

_______________________________________________
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: Goofy question about Datagrids

dunbarxx
DG's have individual fields at each "cell". You could store any custom formats representing the displayed values in a custom property of the relevant field, and extract that string instead of the visible one.

Of course, this could be managed in the group script as well, since those fields respond to "the target". It is all made in LC, after all.

Craig
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Sri
In reply to this post by Bob Sneidar-2
Bob Sneidar-2 wrote
I store datetime data in "international" format, but I want to display it in a kind of short date/time format. .............. I would need to display a value one way while leaving the underlying format as is.

Bob S
on FillinData pData
  set the text of me to fConvert(pData)
end FillinData

function fConvert pDate
  /*convert the original format to display format*/
end fConvert

Regards,
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Bob Sneidar-2
Thanks I'll give that a try.

Bob S


On Nov 2, 2016, at 13:21 , Sri <[hidden email]<mailto:[hidden email]>> wrote:

on FillinData pData
 set the text of me to fConvert(pData)
end FillinData

function fConvert pDate
 /*convert the original format to display format*/
end fConvert

Regards,
Sri

_______________________________________________
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
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Sri
Hi Bob:

Make it

set the text of field 1 of me to ............

just to be sure. You can have a group of more than one object in the cell.

Regards,
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Bob Sneidar-2
Well I discovered that what you CANNOT do is call a user-defined command or function that has not been loaded yet, as in a front or back script that has not been inserted yet. If I do, when I open the stack I get an error. I suppose I could do the inserts in a preopen handler, but the scripts are contained in buttons in the stack that is not open yet. Not sure how that would play out.

Bob S


On Nov 2, 2016, at 16:30 , Sri <[hidden email]<mailto:[hidden email]>> wrote:

Hi Bob:

Make it

set the text of field 1 of me to ............

just to be sure. You can have a group of more than one object in the cell.

Regards,
Sri

_______________________________________________
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: Goofy question about Datagrids

dunbarxx
Hi.

Can you do it with the "startUp" message?

Craig
Sri
Reply | Threaded
Open this post in threaded view
|

Re: Goofy question about Datagrids

Sri
In reply to this post by Bob Sneidar-2
Bob Sneidar-2 wrote
Well I discovered that what you CANNOT do is call a user-defined command or function that has not been loaded yet, as in a front or back script that has not been inserted yet. If I do, when I open the stack I get an error. I suppose I could do the inserts in a preopen handler, but the scripts are contained in buttons in the stack that is not open yet. Not sure how that would play out.

Bob S
Bob,

May be I have not understood what you are trying to do, but a user-defined function in the same script as the FillinData handler of the column in question works perfectly for me.


Above is the original phone number format. I tried to convert it by adding an fConvert function in the column behavior of the "Phone" column, as follows:

on FillInData pData
   -- set the text of field 1 of me to pData
   set the text of field 1 of me to fConvert(pData)
 end FillInData
 
function fConvert pData
   set the itemDel to "-"
   return "(" & item 1 of pData & ")" &&  (item 2 of pData) && (item 3 of pData)
end fConvert

It works perfectly; here's the image.



I hope the images show in the post (My post wouldn't make any sense otherwise!)

Regards,
Sri