Hello,
I'm fairly new to Kendo ( still testing it for my mobile app ) and i'm trying to display your list of friends (pulled from FB) in a scroll view with their names and pictures. It can go up to 1K + Friends and when switching from a profile to another, the list of friends has to be re populated. I can't have it work, and I'm a bit worried about performances when listing 1000+ friends on the page.
So Basically, I have a ScrollView that I'm trying to rebuild (or at least remove the old data and add new data) when a user get back to the previous page and come back again to this page. It's like a profile page. When you go there for user id = 1 you have some information and a scrollview with his friend's name and pictures, and when I go to another user (id = 2) then I want to change every information on the page, including the information bound in the scrollview.
From what I understand, one can only change the pictures of the scroll view by initiating the view. It doesn't seem to work when data-show is triggered and I have a feeling that we should re-initiate the page completely... Am I right ? Doing the scroll view methods such as SELECTOR.data("kendoMobileScrollView").setDataSource(friendsToInvite) or scrollview.refresh() doesn't seem to work.
Am I doint something wrong or should I re initialize the view everytime a user go back and forth on the different user profiles ? How can I do this ?
here is my HTML:
and My JS:
All that is commented is something I've tried. whithout success.Also, you'll notive that I've filled the scroll view twice: once for the "initialization" with empty data and another one with the data I want to use. The fact that the when() method delay the construction of the scroll view makes it bug. I don't know why.
I'm fairly new to Kendo ( still testing it for my mobile app ) and i'm trying to display your list of friends (pulled from FB) in a scroll view with their names and pictures. It can go up to 1K + Friends and when switching from a profile to another, the list of friends has to be re populated. I can't have it work, and I'm a bit worried about performances when listing 1000+ friends on the page.
So Basically, I have a ScrollView that I'm trying to rebuild (or at least remove the old data and add new data) when a user get back to the previous page and come back again to this page. It's like a profile page. When you go there for user id = 1 you have some information and a scrollview with his friend's name and pictures, and when I go to another user (id = 2) then I want to change every information on the page, including the information bound in the scrollview.
From what I understand, one can only change the pictures of the scroll view by initiating the view. It doesn't seem to work when data-show is triggered and I have a feeling that we should re-initiate the page completely... Am I right ? Doing the scroll view methods such as SELECTOR.data("kendoMobileScrollView").setDataSource(friendsToInvite) or scrollview.refresh() doesn't seem to work.
Am I doint something wrong or should I re initialize the view everytime a user go back and forth on the different user profiles ? How can I do this ?
here is my HTML:
<!-- Event Page !!! Inherit the layout just above for footer and header -->
<
div
data-role
=
"view"
data-layout
=
"overview-layout"
data-show
=
"initEvent"
id
=
"event"
>
<
div
data-role
=
"content"
class
=
"content"
>
<
div
id
=
"eventContent"
></
div
>
<
div
>
<
div
id
=
"friendsToInvite"
></
div
>
</
div
>
</
div
>
</
div
>
<
script
id
=
"friendsToInvite-template"
type
=
"text/x-kendo-template"
>
<
p
>#= name #</
p
>
<
div
style
=
"width: auto; height: 180px; background: url('https://graph.facebook.com/#= fbid #/picture?type=large') no-repeat center;"
></
div
>
<
p
><
button
>Invite</
button
><
button
>Dont show me again</
button
></
p
>
</
script
>
and My JS:
var
y = 3;
function
initEvent( e )
{
//Get the "Key" of the event, which is linked to the id somehow
var
key = e.view.params.key;
//Retrieve the event info from the cache with the key !
var
event = Event.retrieveFromKey( key );
// Append the template of the event upon the event info
var
template = Handlebars.compile( $(
'#eventTemplate'
).html() );
$(
'#eventContent'
).prepend( template( event ) );
//The next ones are about getting your friend list for this specific event based on the algo
// Generate an empty kendo Scroll View
var
friendsToInvite =
new
kendo.data.DataSource({
data: []
});
$(
"#friendsToInvite"
).kendoMobileScrollView(
{
dataSource: friendsToInvite,
template: $(
"#friendsToInvite-template"
).html(),
contentHeight: 300,
enablePager:
false
});
$.when( Event.getFriendsList( event.id ) ).done(
function
( friendsList )
{
if
( friendsList.length > 0 )
{
for
(
var
i = 0; i < y; i++ )
{
friendsToInvite.add( { name: friendsList[i][
"name"
], fbid: friendsList[i][
"fbid"
] } );
};
$(
"#friendsToInvite"
).data(
"kendoMobileScrollView"
).setDataSource(friendsToInvite);
// y++;
// console.log(y);
// if (y > 5) {
// console.log("refresh");
// console.log ( scrollview );
// $( "#friendsToInvite" ).data("kendoMobileScrollView").setDataSource(friendsToInvite);
// scrollview.refresh();
// $( "#friendsToInvite" ).empty();
// };
// console.log(friendsToInvite);
// $( "#friendsToInvite" ).kendoMobileScrollView(
// {
// dataSource: friendsToInvite,
// template: $( "#friendsToInvite-template" ).html(),
// contentHeight: 300,
// enablePager: false
// });
}
else
{
console.log(
"Got to be creative on this one ..."
)
}
});
}
All that is commented is something I've tried. whithout success.Also, you'll notive that I've filled the scroll view twice: once for the "initialization" with empty data and another one with the data I want to use. The fact that the when() method delay the construction of the scroll view makes it bug. I don't know why.