Integrated Application Platform › Forums › General › ListView – how to make visible added rows?
- This topic has 4 replies, 2 voices, and was last updated 8 years, 2 months ago by
ajith.
-
AuthorPosts
-
March 26, 2015 at 4:39 am #1164
ajith
ParticipantHi,
I have a custom control in which is a ListView defined as (ListView tips:true name: ‘view’) and a Button.
In the On_Button method, I need to calculate something and populate the ListView with those values.
The code inside the method include:
.view.SetColumns(#('disease', 'agent', 'modal', 'willcox) for i in ob { row = Object(disease: i['disease'], modal: i['modal'], willcox: i['willcox'] , agent: Query1('FoodPoison', fp_name: i['disease']).fp_type) .view.Addrow(row) }
The rows doesn’t get added properly. All cells in a row show disease member of the consecutive objects supplied. What am I am missing?
I tried AddColumns method to add columns one by one.I tried Ensure Visible method after adding the rows. Both did not help.
2) A minor mistake in User Manual:
Setcolumns(cols) is written with lower case c. It is uppercase C in the library.3) Not a mistake, but a deviation from convention that you usually follow (which you may be knowing)
The Getrow and Addrow methods are named with the first letter of the second word in lowercase.Thanks,
ajithMarch 26, 2015 at 9:27 am #1165amckinlay
KeymasterI will correct the help, thanks.
Here is an example that works for me:
Window(Controller { New() { .list = .FindControl('List') .list.SetColumns(#(name, age)) } Controls() { return ['Vert', ['ListView', style: LVS.REPORT], #(Button Add)] } On_Add() { .list.Addrow(#(name: Bob, age: 24)) .list.Addrow(#(name: Sue, age: 19)) } })
March 27, 2015 at 3:06 am #1166ajith
ParticipantHi Andrew,
Though I did not understand what was wrong originally, it is working now.
Can you please explain the difference between using [] and () and why [] was needed in some places and () in others while defining the Control() method?There are two more things that I want in my ListView –
1) After adding the rows, how to sort the listView by any one column?
2) How to allow clicking the listView header buttons to sort by that column?Thanks,
ajithMarch 27, 2015 at 11:51 am #1167amckinlay
Keymaster[…] is equivalent to Record(…) in code, or to #{…} in a constant
I use it because it is shorter
Although you have to be careful because Record is slightly different from Object1) You can sort your data before you add it to the list view. e.g. data.Sort!(By(#name))
Or if you use DragDropListViewControl (see below) you can call the SortList method.2) If you use DragDropListViewControl instead of ListViewControl then you can click on the header to sort. (And you can also rearrange the columns.)
March 30, 2015 at 5:15 am #1168ajith
ParticipantAndrew,
Thanks for your help. I used the DragDropListView and things are as I wanted. There was a small problem though. I had used .list.SetColumnName(‘disease’, “Disease”) to set the header for the columns. With this line in my control, an error to the effect – the member Disease is not present was coming up. I found that the .GetHeader was returning a number and so I couldn’t discern what was wrong. Anyway, I tried adding a field definition for the object members and removed the line defining the header from my control which was successful.
Thanks,
ajith -
AuthorPosts
- You must be logged in to reply to this topic.