@marksmithhfx
Dear Mark, thank you for the picture. I made a screenshot and attach it to this message. Your date-time-item list looks very nice.
Working with data in a database in one thing. What you actually export to LiveCode may already be prepared on the database level or your LiveCode Server / PHP ... server app/s.
Your SEARCH field is the entry for searching the database. It has nothing much to do with the Data Grid (DG).
So, let us assume that as the result of your search you are receiving data in the form of XML or JSON or import data whatever other way and manage them on the client level (your desktop or mobile application.)
XML/JSON already are structured hierarchical lists, and the Array in LiveCode also is suitable allowing for hierarchically structured data. This we should not confuse with the way SQL is storing and managing data -- mainly meant to keep data separate (your database design). Possibly certain calendar data or hierarchical data are better stored and managed in so called NoSQL databases. Whatever you are using, you can definitely select the data you need.
So, the main thing for you is to receive the data in such a way that you know that at a certain date there are some items in the "group" of that date. You would
sort by date and below
sort items by starting time listed for that date. In SQL each item will already have a date and such time entries. Therefore, you would ORDER BY or manipulate using LiveCode script that for all items of one date the header for that date group will be that date.
Now, since the date in the original is part of the item, you would have to separate it out into it's own "label" either again on the database level or through your LiveCode script.
Let us look at the DG, and I assume that you worked with the FORM style of the DG (look at the LiveCode lessons, as I did) the rows are just containers.
1. There are rows with dates such as WEDNESDAY, FEB 17
2. There are rows with items such as "CCDSS Enhancement" or whatever
3. There seems to be a starting and end time
4. Rows below a date have two lines with a description and a time field.
So, this information is put into the array of the DataGrid "dgData" using a first key "i" -- an integer -- that indicates the row number. The second level are keys such as the name of the field "date", field "time1", field "time2", field "desc1", field "desc2" You will also need some information that you know which of the array records indicates that it is used as the label of the date, or it is the item of a date group. This can be user defined property in the date field, or a separate field with a "true" or "false" value.
Your array for the dgData of your DG group. This needs to be filled with your sorted data.
Code: Select all
// i = 1 to n equals row 1 to n
// Since the date header is a separate row, this header row has to be created before inserting it here
// It can be done on the database level or in LiveCode script. The date field nevertheless is part of
// each row, just in the item rows the date field is invisible
tArray [i]["date"] -- Field date (formatted)
tArray [i]["desc1"] --Field description
tArray [i]["time1"] -- Start time
tArray [i]["desc2"] -- Whatever, seems to be reference to a company
tArray [i]["time2"] -- Ending time
tArray [i]["rowtype"] -- Field with the value true or false
---
// After filling this array, set the dgData of group "<your DG group name>" to tArray
Let us look at the rows you want to display:
- Row 1: Only show the date. It can be copied from the date field to the label field, or you can simply only show the date field and hide all other fields. Field "rowtype" = true
- Row 2: Hide the label and date field. Show the fields Description, time, Show your first entry for this date. Field "rowtype" = false.
- Row 3: Hide the label and date field. Show the fields Description, time, Show your second entry for this date. Field "rowtype" = false.
- Row 4: Only show the date again for the next group. Field "rowtype" = true
How the row display, either as a header (the date) or as items (with times) in this example depends on the value "true" or "false" in the "rowtype" field, and you need to script this in the behavior script as I did yesterday and showed the script.
So, all you want is perfectly possible. If you want to change the color of your vertical bar lines or put some other background color of items, again, in the behavior script you can define this for each row depending on certain criteria that you have to program.
As I am anticipating that some readers here are new to LiveCode or not too familiar with the language, I am trying to describe as much as possible not assuming a lot of prior understanding. What one should know for working with DG's ("data grids" or "datagrids") in LiveCode: How to work with arrays in LiveCode, know about LC groups and how they work and how to edit them, and last but not least understand behaviors. The DG is just a complex group of groups. It has an API (application programming interface) allowing you to interact with it, and there are editing possibilities using the Property Inspector of the DG. When you choose the Form style of the DG, you can go to the template group form (this contains your icons, fields, bars, widgets, whatever) and arrange them there. The template is needed for the DG to copy it and it's controls/objects to the rows when there is data to be presented in the rows. The template for each DG is in a separate stack. Opening it first, you will not understand what is happening there and what you should do now. There is a field "label" which is not really visible, and a graphic "background" also empty. Go through the LiveCode Lessons to get an idea. Also from the Property Inspector you have access to the behavior script. In this script you define which fields/controls of your row to show or hide, change their color or other dependencies and how they display.
.