Display To-Do Items in the UI

Now we will look at how to display the to-do items that we can create.

What We Are Going To Do

When the user clicks on a project in the left column a list of to-do items should appear to the right. We are now going to add the code that does that.

Update the uiPopulateToDos Command

Replace the uiPopulateToDos command in the card script with the RevTalk code below. After you insert the code we will go through the relevant parts.

----------

Copy & Paste The Following Code

----------

command uiPopulateToDos

put the uSelectedProjectID of group "ProjectsPeople" into theProjectID

put sqlquery_createObject("todo_items") into theQueryA

sqlquery_set theQueryA, "order by", "sequence"

sqlquery_set theQueryA, "conditions", "project_id is :1", theProjectID

sqlquery_retrieveAsRecords theQueryA, theRecordsA

put the result into theError

if the result is empty then

set the dgData of group "ToDo" to theRecordsA

end if

if theError is not empty then

answer "Error populating to-do items:" && theError & "."

end if

end uiPopulateToDos

Using the 'conditions' Property of a SQL Query Object

The RevTalk that displays to-do items is very similar to the RevTalk that displays projects. The only real difference is that you need to set the conditions property of the SQL Query object in order to filter the list of to-do items that are returned.

The 'conditions' property is part of what defines the WHERE clause of the SQL query that is generated. Since to-do items are linked to projects we only want to retrieve to-do items that are linked to the currently selected project (1).

I would like to point out two things in the line that sets the 'conditions' property. First is that you can use english search terms. For example, I use 'is' rather than '=' (2). You can also use terms like 'begins with', 'ends with' and 'is in'.

Second is that when setting the 'conditions' property you can using bindings. Notice the ':1' in the string (3). Using bindings can make your code easier to read. In addition, SQL Yoga will cleanse special characters that appear in strings that you add using bindings. The ':1' in the string is replaced by the next parameter passed to sqlquery_set (4). I could also include a ':2' or ':3' in the string if I passed in additional parameters.

Verify

To verify that the to-do item was created click on New Projects and execute uiPopulateToDos in the message box (1). You should see the New Task entry appear in the to-do list (2).

0 Comments

Add your comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.