Kendo ListView - SignalR - Edit & Update client datasource

5 posts, 0 answers
  1. Matt
    Matt avatar
    43 posts
    Member since:
    May 2013

    Posted 11 Dec 2013 Link to this post

    I could have two clients editing the same page and want the changes adjusted immediately without refreshing the data source.

    The listview is setup fairly normally. It feeds of a data source and in turn sends updates through a MVC controller update.

    When the MVC action processes the update it notifies connected users to the group of the change(s) to items. This notification is the same response that the JSON Result responds with effectively.

    Updating all clients is close to working:
    Scenario 1: Client 1 and 2 goto the same page. Client 1 edits a field and those changes are reflected on client 2's screen.
    Scenario 2: Client 1 and 2 edit the same row. Any saved changes by either are updated to the others edit fields.

    The problem im getting is when Client 2 begins editing a different row. When it goes to Client 1 it is more seen as the edit state of the data row. A little more challenging to understand what i mean.
    So yes... im more hiting my way through the data source to have my changes there. The SignalR function will seek out the row(s) to update and run:

    01.for (var i = 0; i < menuItems.length; i++)
    03.    var item = menuItems[i];
    04.    var dataSourceItem = this.findById(item.Id);
    05.    if (!dataSourceItem) { continue; }
    07.    var thumbArray = new
    08.    dataSourceItem.set("WebName", item.WebName);
    09.    dataSourceItem.set("WebDescription", item.WebDescription);
    10.    dataSourceItem.set("Thumbs", thumbArray);
    11.    //however each item is now dirty ... and i don't want to send off them again to be saved.
    12.    dataSourceItem.dirty = false;
    14.if (this.dataSource.hasChanges()) {
    15.    //this should always be a no now.
    16.    console.log("has changes");
    this.findById is digging through the method and returning the correct item.

    How can I update the data item in the data source and have it think its the pristine saved version after the signalr update? As client 1 and 2 sort of move into a protective - only display saved changes mode once editing has started. Clicking on update on a modified row by a different client will have the correct signalr pushed values but they are not on the item display template.

    Best Regards,
  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 12 Dec 2013 Link to this post

    Hi Matthew,

    I prepared a sample application which shows a possible implementation. It is using the grid but the same should work with the listview.

    Atanas Korchev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Matt
    Matt avatar
    43 posts
    Member since:
    May 2013

    Posted 12 Dec 2013 Link to this post


    I presume it was those two lines that I was after. My computer is installing .net 4.5.1 at the moment so i cant run the project to confirm just yet. But copying those lines instead of have dataItem.set("field", value) etc ... i didn't know 'accept' did that, which is useful for one of my other problems.

    It updates properly from between client 1 and client 2 as before. The problem only occurs once both clients have edited the same row. The display template displays the listview's 'last saved' version only. Clicking edit on that same row and the row will display the pushed changes by SignalR in the edit template which continues the next 'save changes' or 'cancel' steps. Editing any other row that hasnt been modified by the opposite client still works.

    Currently using the internal build v2013.3.1122. I will test out the sample project shortly.
  5. Matt
    Matt avatar
    43 posts
    Member since:
    May 2013

    Posted 12 Dec 2013 Link to this post

    Thanks Atanas Korchev

    The grid is doing what I expect. I'll test it to see if it does the same thing with the listview
  6. Matt
    Matt avatar
    43 posts
    Member since:
    May 2013

    Posted 12 Dec 2013 Link to this post

    List view templates - display & edit have the expected current state (in your attached project)... which means that my code is the one doing something odd.


    The lines above are always firing from a change by another client on signalr. Ive checked my build version on the project and that is fine as well. I'll keep playing with it.
Back to Top
Kendo UI is VS 2017 Ready