Search Support
-
Andrzej MichalecFebruary 13, 2017 at 2:10 am #3675
Dear team,
there is an issues with Table widget when trying to sort by column bound to nested object. Table bound to “list” object sorts fine when column is bound to first level attribute e.g “list.currentItem.name”, however biding column to nested attribute like “list.currentItem.address.city” and sorting by this column gives different quasi-random order each time. This happens for columns that are rendered with Output Text so that display text is the same like underlying data we sort by. Quick workaround would be to introduce extra business object with flattened structure, and copy nested data over to it for sorting purposes, in long term however binding to nested objects should not interfere with sorting. Please confirm and plan for fix.regards,
-andy.SPARK SupportFebruary 17, 2017 at 1:13 pm #3753Hi Andy,
This is working as designed. Only simple types are handled by default.
However, the Columns configuration option provides the option to Render As a Custom cell. (See screenshot)
A method can be called from the On Custom Cell event. In the example I have provided, both column indexes require the same logic as they are simple types within the Address object. (See screenshot)
Then the following script can be added to a Custom HTML, or other location to store the JavaScript:
<script>
function customCell(table,cell)
{
cell.setSortValue(cell.value);
return “V”;
}
</script>Regards,
Stephen P.
Andrzej MichalecFebruary 20, 2017 at 8:56 am #3778Hi Stephen,
I do not see any screenshot 🙂
What about situation that we play with tens of object types, with different depth levels and composed in tables in many ways. Let assume that each of these attributes can be rendered as output text. Is there a way to make up single custom renderer that binds to any deep property and makes column sortable? Producing tens of custom renderer for each business object type and/or depth would not be acceptable
regards,
-andy.SPARK SupportFebruary 22, 2017 at 11:50 am #3802Hi Andy,
My apologies for not having uploaded the screenshots.
In the case that you provided, the underlying Address object contains simple types such as String for Street and City. Therefor the simple Customer Render code of cell.setSortValue(cell.value); works with the simple type. However, if you have a complex type within a complex type within a complex type, such as Managers > Person > Address, the setSortValue() would need more complex logic to handle what to use of the sort.
This would be my assumption. In this hypothetical situation, the column would be bound to list.currentItem.person.address.city. In this case, even though the simple type is a property of the third level, cell.setSortValue(cell.value); will still work.
Regards,
Stephen P.
Akash GuptaMay 15, 2017 at 8:10 am #4322I have used the above method to set the sort value in lowerCase but I am facing 1 issue while sorting.
I have a table which has 3 pages(1o rows each). On Page Load The values are only updated on the first page .(It should be updated in the entire table on all 3 pages). Due to this the sorting is not working correctly and I have to click on the sort button multiple times to get the correct sorting.
Is there any way to update the values throughout the table. Below is my function which i am calling on “On Custom Cell:”
function renderCell(cell) {
if (cell.colIndex == 0) {
cell.setSortValue(cell.value.toLowerCase());
return “S”;
}
}-Regards
Akash
SPARK SupportMay 16, 2017 at 4:07 pm #4324Hi Akash,
To work around this issue, I would start with no default Page Size in the Table configuration to allow all rows to load. Then set the page size to 10 from the Table On Load event using me.setPageSize(10);
Regards,
Stephen P.
Akash GuptaMay 16, 2017 at 11:45 pm #4325Hi Stephen,
Thanks for the quick response , I tired setting the page size on Table OnLoad but it is not working.
Is there any other configuration I have to do.
SPARK SupportMay 18, 2017 at 9:55 am #4332Hi Akash,
The only configuration I have done is left the Initial Page Size blank and pasted me.setPageSize(10); into the Table On Load.
(See attached screenshot)
Regards,
Stephen P.
Nithin KoshyDecember 4, 2018 at 3:16 am #5347Hi,
I am trying to sort the table column bind to a date variable. It is sorting based on the first digit in the date – meaning if I have 1.10.2018, 11.7.2018, 12.12.2018 – after sort it shows as 1.10.2018,11.7.2018,12.12.2018. Does the sort consider the variable data type or the Coach view binding data type? (want to understand the impact- if I bind date variable to a output text)
Any help?
SPARK SupportDecember 7, 2018 at 7:41 am #5358Hi Nithin,
The default sort function in the Table control is very simple. See the above discussion on creating a custom sort function using the Render As Custom setting and the On Custom Cell event.
Instead of simply calling cell.setSortValue(cell.value); you can use some custom logic such as:
var v = cell.value.split(“.”); if (v[0].length == 1 ) {v[0] = “0” + v[0] }; cell.setSortValue(v[0]);
This would sort just on the month. But you can repeat the logic for the day and year, or reorder the sort value for the year + month + day;
Regards,
Stephen P.
Fabrizio LamariSeptember 26, 2019 at 10:29 am #5568Hi everybody,
First I want to thank you about the hint regarding the ” return “V”; ” in your example, that’s exactly what I was searching for.
I’ve a table with a column containing a Coach View and therefore I needed to set a custom sort value for the filtering to work, but I didn’t wanted to generate all the complex HTML I’ve already configured in my Coach View. Regrettably the documentation (http://support.salientprocess.com/docs/enterprise/Table.html) does not tell anything about the return value you used like “V” and “S” which returs the column content as already configured. Could you please tell me more about this return values and where I can find which one exists and what they exactly do.
Thank you very much for your further explanation.
Regards,
Fabrizio L.
SPARK SupportSeptember 26, 2019 at 10:57 am #5570Hi Fabrizio,
Look in the Business Objects contained within the BPM or SPARK UI toolkit, and you will find the TableCellRenderType and ServiceDataTableCellRenderType definitions. These contain the appropriate Selection Choices, or return types, for each Table control.
Of course, if the Table Column is set to Custom, there is not point in returning “C”. An HTML element should be returned instead, if the Coach View or Simple HTML rending is not applicable.
Regards,
Stephen P.
Fabrizio LamariOctober 1, 2019 at 2:12 am #5572Hi Stephen,
Thank you for your immedate reply and the hint to look in the UI Toolkit. It works great now and I unerstand the implementation.
Regards,
Fabrizio
-
|
You must be logged in to reply to this topic.