on 2003 Dec 15 3:48 PM
I would like to find out how do i facilitate automatic sorting of table columns in a Webdynpro Table.
.V
Hi Jake,
I am not quite sure what you mean with "automatic" sorting.
One thing you could do is, to create an event for the header of the table. You choose your own criteria, how to sort the table columns. It is our intention or the intention of the development environment not to have a kind of automatic sorting, because how should the table know how to sort the data? Especially if you have images or icons or things like that in your table. But what you could do is to use the Event for the header and then you are able to sort the context with your own logic.
Hope that helps.
Many greetings,
Karin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Do you mean i have to implement an internal sorting mechanism in the Supply Function where by
1. i look up all the elements under the node (which is designated source of data for the Table control)
2. compare their attribute and sort these objects accordingly and
3. based on the sort sequence, insert them into a empty collection one by one and
4. finally bind them to the relevant node.
Also kindly let me know how do i implement a Supply function.
The node in the View Controller which acts as a data source for the table control to display data is mapped to a similar node in the Global Controller which is further bound to the model.
How do i implement s supply function.
.V
Hi Jake,
1. you can sort elements in each type of node using the method wdContext.nodeXXX().sortElements(comparator). Therefore you don't have to remove, sort and rebind a node-collection, which covers the points 1 to 4. It doesn't matter, if a node is mapped in that case.
2. A supply function can be bound to every type of node, model nodes and value value nodes. To be honest, i didn't try to use a supply function for a model node yet, but nevertheless it's possible to bind a supply function to such a node, if it's not mapped (model nodes which you bind to the model directly by Edit model binding, not by Create context mapping).
To implement a supply function, select the node in the controller context and look at the properties view. There's a line "supplyFunction", where you can add a method which you then have to implement in the Implementation view. You will always get the parent node for creation of elements and adding/binding and the parent element if there is such. There is an example in the NetWeaver DeveloperStudio help.
Hope that helps.
Regards
Stefan
Hi Stefan,
I Still cant make out what exactly needs to be done.
If you are saying that point 1 described (calling wdContext.nodeXXX().sortElements(comparator) ) solves everything then why do i need to go for a supply function.
i need to implement sorting when the user clicks on the header and hence i have implemented an event handler (which might possibly call the .sortElements() function )
Also kindly let me know how do i use a comparator in this function call and how do i inform the sort function about the column (i.e. attribute under the node which acts as a data source for the table) by which i need to sort.
a simple procedure with some source code might really help.
.Vishal
Hi Vishal,
The sort method asks everytime the comparator, if the method has to compare two lines, which one is "smaller" than the other one. In other words: within the code of the comparator is defined, which column has to be compared.
An example: Assuming, we have a node "Customers", which I want to sort by attribute "name". The comparator would look like this:
// create an anonoymous implementation of the interface Comparator
Comparator comparator = new Comparator() {
// this method compares two instances of the list (in our case
// CustomersElements)
int compare(Object a, Object b) {
// the method gets Objects, but we know that they're
// CustomersElements
CustomersElement ea = (CustomersElement)a;
CustomersElement eb = (CustomersElement)b;
// compare the names (String.compareTo does exactly what we need)
return ea.getName().compareTo(eb.getName());
}
}
// sort using this comparator
customersNode.sort(comparator);
Hope that helps.
Best regards,
Karin
I am including the code segment if that might help.
V
public void onActionHeaderSelect(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionHeaderSelect(ServerEvent)
// create an anonoymous implementation of the interface Comparator
java.util.Comparator comparator = new java.util.Comparator() {
// this method compares two instances of the list (in our case
// CustomersElements)
public int compare(Object a, Object b)
{
// the method gets Objects, but we know that they're
// CustomersElements
IPrivateNewLdapResult.ILdapRecordElement ea = (IPrivateNewLdapResult.ILdapRecordElement)a;
IPrivateNewLdapResult.ILdapRecordElement eb = (IPrivateNewLdapResult.ILdapRecordElement)b;
// compare the names (String.compareTo does exactly what we need)
return (ea.getFirstAttrValue().compareTo(eb.getFirstAttrValue()));
}
};
// sort using this comparator
wdContext.nodeLdapRecord().sortElements(comparator);
//@@end
}
Hi Karin,
I have corrected the class to which the objects were casted and it compiles successfully and does not throw any exception at runtime. But the sorting does not happen.
To describe a little bit more about the context of the above View i will give the context design
-Context
-LdapResults (0..1)
-ldapRecord (0..n)
-firstAttrValue (string attribute)
-secondAttrValue (string attribute)
-thirdAttrValue (string attribute)
-fourthAttrValue (string attribute)
Dear Vishal,
I guess this is the point. There are some bugs within that version. We will provide a new version on SDN based on Web AS 6.40 middle of February. I will inform you within SDN as soon as it is available. I would suggest to use this one then. Would that be an option for you?
Best regards, Karin
Dear Karin,
The Option looks great but i have certain time constraints on my side and Feb might
be too late. May i ask which build version/release do you use right now at your end.
I guess if it works at your end then i will plan to port my source code to the
version/release that you are using.
It not just about the table column sorting but the other issue that i have posted on this forum about a Component calling another Component in one of it's view is a major one. This is a real show stopper as i cant unify/link the different components i have right now.
.V
Dear Vishal,
Because it is only a Sneak Preview version and for trial and play around with it only, there are some missing features and functions and some bugs as well. The next version will be much more stable and includes a lot of new features (graphical tools, new UI elements, and so on...) you can play around with. Even the new version is not made for productive usage. I am very sorry, if I have to say that I can not provide you with a newer version until mid February.
I will inform you as soon as it is available. Hope that is okay for you.
Best regards, Karin
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.