on 12-23-2008 7:05 AM
Hi All.
I have a table whose one of the columns display numbers with data type string. This is becuase :
1. RFC gives me as String.
2. I have to display blank in case no value or zero is present (since int, long etc default to Zero, hence
not used).
I have to sort this column as a number.Since the datatype is string, it sorts the numbers as string
for example : if we have values like : 2, 4, 3, 10, 19, 15, 20, 22
currently as String it sorts as follows : 10, 15, 19, 2, 20, 22, 3, 4.
but i want as follows : 2, 3, 4, 10, 15, 19, 20, 22.
Useful answers will appreciated.
Thanks and regards,
Aditya Deshpande.
Hi Vinod,
My initial implementation was using table sorter class....
I have achieved my requiremnt by modifying your previously mentioned method... Thanks for your help...
Points to you...
Regards,
Aditya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
sorry guys..
Both the ways did not work...
1. i have blank.Hence it throws parse error
2. i have other columns with different datatype like date, which have to be sorted also.
Do we have any datatype through which we can achieve the same with displying blank in column and sorting as integer...?????
Thanks and Regards,
Aditya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In order to sort the node with attribute of type string; please use the following code..
Here use the node where you store the string value..
wdContext.nodeTest().sortElements(
new Comparator() {
public int compare(Object o1, Object o2) {
// TODO Auto-generated method stub
IPrivateExperimentView.ITestElement ele1 = (IPrivateExperimentView.ITestElement)o1;
IPrivateExperimentView.ITestElement ele2 = (IPrivateExperimentView.ITestElement)o2;
return Integer.parseInt( ele1.getNumStr()) > Integer.parseInt( ele2.getNumStr()) ? 1 : -1;
}
});
input : "2", "4", "3", "10", "19", "15", "20", "22"
result : "2", "3", "4", "10", "15", "19", "20", "22"
vinod
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for quick reply,
RFC gives me output as number or BLANK.
If blank i have show as blank in table.
But when i sort the column ,it has to sorted as number with blank being considered as zero.
Thanks and Regards,
Aditya Deshpande
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Create a refrence to Comparator GLobally i,e under @@begin Others
Comparator c;
write this under the sort action.
wdContext.node<yourNode>.sortElements(c);
Regards,
Satya.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can try the following:
Since the RFC is returning values as Sring, you can parse the String to integer before copying the data into table column.
Parsing a string to interger is done as:
int i = Integer.parseInt(<string>);
In this scenario,you will have to be sure that the string returned is always a numeric value.
regards,
amit bagati
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.