Discussion:
Listbox sort control?
Keith Goebel
2016-07-18 13:31:05 UTC
Permalink
Using 4D v15.2, I am converting included forms into selection based listboxes.
In many cases I would like to have a particular column sort by a method call and the others by normal listbox sorting.
So, the listbox has sorting turned on.

Is there any parameter I can insert into the On Header Click event that will enable me to do a custom sort in one column and a normal listbox sort for the other columns?
In other words:
If (Form Event = On Header Click)
$Header_Button_p:=OBJECT Get pointer(Object current)

If ($Header_Button_p=(->bMy_Button_l)) //special column sort
Do_my_Sort_Here

` do something here to disable the listbox sort for this click

Else
`do nothing - let the listbox do its sort
End if
End if
TIA, Keith


**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
***********************************************************
Keith Culotta
2016-07-18 14:05:55 UTC
Permalink
If (Form event=On Header Click) & (Self=(->Header_Cost))
$0:=-1
End if

On Header Click: ...If the Sortable property was checked in the list box, you can decide whether or not to authorize a standard sort of the column by passing the value 0 or -1 in the $0 variable:
- If $0 equals 0, a standard sort is performed.
- If $0 equals -1, a standard sort is not performed

Keith - CDI
Post by Keith Goebel
Using 4D v15.2, I am converting included forms into selection based listboxes.
In many cases I would like to have a particular column sort by a method call and the others by normal listbox sorting.
So, the listbox has sorting turned on.
Is there any parameter I can insert into the On Header Click event that will enable me to do a custom sort in one column and a normal listbox sort for the other columns?
If (Form Event = On Header Click)
$Header_Button_p:=OBJECT Get pointer(Object current)
If ($Header_Button_p=(->bMy_Button_l)) //special column sort
Do_my_Sort_Here
` do something here to disable the listbox sort for this click
Else
`do nothing - let the listbox do its sort
End if
End if
TIA, Keith
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
**************************************
Chip Scheide
2016-07-18 14:17:27 UTC
Permalink
this may have changed...
but I found (v11/12) that my sort code ran
THEN the default sort ran

overriding my 'custom' sort
so.. as I said earlier I use On After Sort to get my custom sort to
display
Post by Keith Culotta
If (Form event=On Header Click) & (Self=(->Header_Cost))
$0:=-1
End if
On Header Click: ...If the Sortable property was checked in the list
box, you can decide whether or not to authorize a standard sort of
- If $0 equals 0, a standard sort is performed.
- If $0 equals -1, a standard sort is not performed
Keith - CDI
Post by Keith Goebel
Using 4D v15.2, I am converting included forms into selection based listboxes.
In many cases I would like to have a particular column sort by a
method call and the others by normal listbox sorting.
So, the listbox has sorting turned on.
Is there any parameter I can insert into the On Header Click event
that will enable me to do a custom sort in one column and a normal
listbox sort for the other columns?
If (Form Event = On Header Click)
$Header_Button_p:=OBJECT Get pointer(Object current)
If ($Header_Button_p=(->bMy_Button_l)) //special column sort
Do_my_Sort_Here
` do something here to disable the listbox sort for this click
Else
`do nothing - let the listbox do its sort
End if
End if
TIA, Keith
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
*****************
Chip Scheide
2016-07-18 14:13:33 UTC
Permalink
I use
On After Sort

Test the column number, or header name for the optional sort

case of
:(form event = on After Sort)
$Column_Number= Get_selected_column_number
IF ($Column_Number = <desired_Column>)
do sort
end case

(above written in email - just an idea for implementation)
Post by Keith Goebel
Using 4D v15.2, I am converting included forms into selection based listboxes.
In many cases I would like to have a particular column sort by a
method call and the others by normal listbox sorting.
So, the listbox has sorting turned on.
Is there any parameter I can insert into the On Header Click event
that will enable me to do a custom sort in one column and a normal
listbox sort for the other columns?
If (Form Event = On Header Click)
$Header_Button_p:=OBJECT Get pointer(Object current)
If ($Header_Button_p=(->bMy_Button_l)) //special column sort
Do_my_Sort_Here
` do something here to disable the listbox sort for this click
Else
`do nothing - let the listbox do its sort
End if
End if
TIA, Keith
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
**********************************************************************
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
***************************
Keith Goebel
2016-07-18 21:44:55 UTC
Permalink
Post by Keith Culotta
If (Form event=On Header Click) & (Self=(->Header_Cost))
$0:=-1
End if
- If $0 equals 0, a standard sort is performed.
- If $0 equals -1, a standard sort is not performed
Keith, that’s exactly what I was thinking of - thanks :-)
I’ll dig through the manuals again.
In case I don’t find it, can you point me at the correct place?
Thanks, Keith
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
*******************************************************************
Keith Culotta
2016-07-18 22:17:46 UTC
Permalink
Sorry, forgot to include the reference: http://doc.4d.com/4Dv15/4D/15.1/Form-event.301-2685904.en.html. Search for "On Header Click".
Also, the code is placed in the listbox method.

Keith - CDI
Post by Keith Goebel
Post by Keith Culotta
If (Form event=On Header Click) & (Self=(->Header_Cost))
$0:=-1
End if
- If $0 equals 0, a standard sort is performed.
- If $0 equals -1, a standard sort is not performed
Keith, that’s exactly what I was thinking of - thanks :-)
I’ll dig through the manuals again.
In case I don’t find it, can you point me at the correct place?
Thanks, Keith
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
********************************************************
Keith Goebel
2016-07-19 12:15:35 UTC
Permalink
Sorry, forgot to include the reference: http://doc.4d.com/4Dv15/4D/15.1/Form-event.301-2685904.en.html <http://doc.4d.com/4Dv15/4D/15.1/Form-event.301-2685904.en.html>. Search for "On Header Click".
Also, the code is placed in the listbox method.
Thanks Keith. I did find it today.
What’s very bad, is that I also discovered (today) that Wayne Stewart told me about this over a year ago - DOH!
Too many “grey” cells accumulating now I think…
Cheers, Keith
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
*********************************************
truegold
2016-07-19 13:47:43 UTC
Permalink
Hi Peter,

Ah I see what you’re doing.

In comparison to what you are building what I am building is trivial and non-dynamic. No need for interactivity.

If I can’t figure out a straight-forward svg approach then I’ll look into a similar approach.

Thanks for sharing.

John...
Can you show me a snippet of code using a couple objects on disk that are
read and embedded as svg objects into the final svg image?
John, this is not that simple as code is split over many method, byut here
I start with a template SVG image - basically empty SVG image with a
$path:=$svgRoothPath +"Template.svg"
$schemaTree:=DOM Parse XML source($path)
...
I have several SVG files containing various drawing elements, let's call
For ($layer;1;$layerCount)
...
For each layer, I create separate group with its own offset within main
$layerRoot:=DOM Create XML element
($schemaTree;"g";"id";"Layer_"+String($layer);"transform";"translate("+String
($left;"&xml")+","+String ($top;"&xml")+")")
Then I open individual SVG files
$path:=$svgRoothPath +"Layer_"+String($layer)+".svg"
$layerTree:=DOM Parse XML source(path)
Now I iterate through elements of Layer SVG and move elements I want to
$child:=DOM Get first child XML element($layerTree)
While (OK=1)
DOM GET XML ATTRIBUTE BY NAME($child;"id";$name)
If (SVG_ElementCanDraw($name))
$newEl:=DOM Append XML element($layerRoot;$child)
End if
$child:=DOM Get next sibling XML element($child)
End while
where SVG_ElementCanDraw is a project method that gets element ID and
decides if this element should be drawn - it means, if it should be moved
to destination image or not - based on what user wants to see.
After the destination image is build, I display it with
SVG EXPORT TO PICTURE($schemaTree;svgImage;Copy XML data source)
where svgImage is a image variable placed in form. What is missing in above
code is (a lot of) error checking and attribute manipulation code, but the
above example should work.
$elementID:=SVG Find element ID by coordinates(svgImage;MouseX;MouseY)
and can either change properties of clicked element - for example, by
changing its position I can allow user to move and/ or rearange elements -
or I can change settings that are used in SVG_ElementCanDraw and rebuild
the image from scratch with different elements etc.
HTH,
--
Peter Bozek
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
***************************************************************
Peter Bozek
2016-07-19 14:46:49 UTC
Permalink
Post by truegold
In comparison to what you are building what I am building is trivial and
non-dynamic. No need for interactivity.
I mentioned interactivity just to demonstrate that approach is rather fast
- it can rebuild the SVG even for large structures fast enough to support
interactive changes.
--
Peter Bozek
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
*************
David Adams
2016-07-20 03:35:16 UTC
Permalink
I've scanned this thread but not followed it in exact detail...so apologies
if I say something silly.

And apologies in advance for saying somethings I've said on SVG thread
before. Here goes:

* SVG is a text format and pretty easy to read.

* I have never used the 4D SVG library and probably never will. Since I
have never used it, I can't say if it's good or bad. (If it works for you,
then it's good.) But I can say that I haven't seen where I need it.

* I didn't use the library because I wanted to understand SVG itself. First
I wrote it by hand (simple stuff). Then I wrote routines to generate SVG
out of 4D. For the complex visualizations I was doing that was...a really
terrible idea.

* Then I moved onto pushing TSV or JSON out of 4D that D3 (JavaScript data
visualization library) consumes. D3 is, amongst other things, an SVG
generator. Thing. Of. Beauty. But I get of course...steering back now...

* Yes, SVG very much has the concept of reusable components. In fact, there
are a couple of varieties with slightly different features:

Defs:
http://tutorials.jenkov.com/svg/defs-element.html

Symbol:
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/symbol

The links above are to two different Web sites, one for each of the SVG
elements. I use both sites a lot and recommend both.

* <g> - the grouping element - is your friend. Tips:

-- SVG size (overall size & number of elements) can become an issue if
you're plotting a lot of objects (thousands). You may never run into this
as a problem (I haven't), but it's worth trying to keep the size down as
you go. Children of a <g> element inherit a lot from the parent <g>. For
example, set the CSS on the g and then everything inside of the g inherits.
Saves a lot of text in the rendered SVG. Likewise, I tend to inject my
event handlers as high "up" the SVG as possible. Events flow up from below
and so you can catch them in, say, a <g>, figure out what was clicked on
and go from there. Better than setting onclick(), etc. on a bunch of
individual rectangles in a single <g>.

-- It's easy to go crazy with <g> elements, but I really like them for
creating 'layers'. Imagine a scatterplot. I'll have a g for the chart and
within that a g for the x-axis labels, y-axis labels, the plot area and so
on. Depending on the data, I might have layers for different data sets.
That's one easy way to hide/show groups of data. (With D3 you can also
select nodes based on a CSS selector so you're in no way limited to
pre-defined groupings...again I stray...again...) Anyway, layers like this
make it pretty easy to read the resulting SVG and spot various errors.
(Like that you've put a bunch of stuff in the wrong spot - that can show up
instantly when you look at your SVG as a tree.)

-- Coordinate spaces! Yeah, g elements are great for resetting x,y to a
local 0,0. Way easier for people like me that just don't naturally plot
grids in their head.

-- G elements are also great for rotating/moving/etc. objects together.
Super easy.

-- svg can contain svg. There are some features/pros/cons to using <svg>
vs. <g>, largely having to do with viewports and setting the initial
position of the element.

So, yeah, try a bit of SVG without the library and you should quickly see
what's easy and what's not. Then you'll be limited by SVG itself, not
whatever subset of features the library provides. And, as has been said, it
really is a lot easier to generate SVG with a good JavaScript library
(like...D3!) than from 4D. No offense. 4D's great for spitting out the raw
data, I use it for that constantly...very handy. But for generating the
SVG? Not so much.

Just my opinions, obviously.
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:4D_Tech-***@lists.4D.com
**************************************

Continue reading on narkive:
Loading...