cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Collection Widget not displaying data as expected

liwei
6-Contributor

Collection Widget not displaying data as expected

Hi guys,

 

In Thingworx Version "ThingWorx 8.4.2-b2151"

 

I'm using Collection widget to make a calendar.

 

I have a datatable with "date" column, column type is "DateTime".

 

When use collection widget, i set the sort column to date column, I have a service to load data from datatable by Month(each time it only load 28-31 rows from datatable base on user's choice of month).

 

Collection widget display correctly on default load, date is in order from 1 to the end of month(Service triggered when mashup loaded), but when user select different month, date order is mess up, no longer sort by date column, even user go back to the default loaded month, date order still mess up.

10 REPLIES 10
raluca_edu
17-Peridot
(To:liwei)

Hi,

Try to check SortField property of Collection widget to always sort data.

Hope it helps,
Raluca Edu
liwei
6-Contributor
(To:raluca_edu)

Thank you for reply! I did used the sortField, which is my "Date" column. 

liwei
6-Contributor
(To:raluca_edu)

 
Chao123
11-Garnet
(To:liwei)

Hello @liwei ,

 

So you're SortField is binded with date? Can we see this?

liwei
6-Contributor
(To:Chao123)

Thank you for reply! Yes it did bind with data, I attached screen shots. I thing I forgot to say is it was working on different server, but it broke after I moved it

Chao123
11-Garnet
(To:liwei)

That is strange, the sorting is done Client-Side and shouldn't be affected. Maybe double check your service.

liwei
6-Contributor
(To:Chao123)

 

Thank you for your help in advance!

Service seems fine, I have attached code at then end.

 

and I found some funny errors as below:

 

1. This is the service bind to collection:

CollectionDataBinding.PNG

2.This is same service bind to a grid(to see selected data)

GridDataBinding.PNG

 

3. In default load, everything seems ok     

 

 

4. After I change Month(changed a parameter input for service "GetCalendarByMonthAndYear"). Collection Display wrong date but Grid is selecting the right date 03/02

ChangeMonth.PNG

5. Same thing happened even I changed the Zoom in size of my browser.........

ChangeZoominLevel.PNG

 

Any possible my CollectionWidget is broken? I'm using Chrome in different machine and get same result.

 

Below is my service Script:

var firstDay = Month + " " + "01" + ", " + Year + " " + "08:00:00";
var firstDayofMonth = new Date(firstDay);
var lastDayofMonth = dateAddMonths(firstDayofMonth, 1);
var query = {
"filters": {
"type": "And",
"filters": [{
"fieldName": "CalendarDate",
"type": "BETWEEN",
"from": firstDayofMonth, // Input parameter for minimum date
"to": lastDayofMonth // Input parameter for maximum date
},
{
"fieldName": "DeviceThingName",
"type": "EQ",
"value": DeviceThingName

}
]
}
};


var result = me.QueryDataTableEntries({
query: query /* QUERY */
});

var sort = new Object();
sort.name = "CalendarDate";
sort.ascending = true;
result.Sort(sort);

Chao123
11-Garnet
(To:liwei)

It seems like your sort.ascending isn't executing properly. Have you tried setting that to false? By default the sort() method will sort in ascending order.

liwei
6-Contributor
(To:Chao123)

I did try enable and disable the sort in collection widget. Neither works. Run service again, change screen zoom in level or change month/year/device will make the display go off.....

 

I'm begin to wonder if my collection widget is broken and should I reinstall it...not that I know how to reinstall...

 

Thanks for helping 

Chao123
11-Garnet
(To:liwei)

I wish I was of more help, perhaps another user can be of more assistance.

Top Tags