Updating MVC Model from WebSocket client

Jun 14, 2014 at 1:36 PM
Edited Jun 14, 2014 at 1:36 PM
Hi Guys,
I am working on an application which is receiving some data from an XSockets connection & I want to display this data using Grid.Mvc. Each time a response comes in I need to update the grid & I was trying to do this using knockout.js. How can I update the data in my IEnumerable model so that I can see the Grid in the View updated.
@model List<ShareefSystems.TimeSharp.Dto.Book>

    var initialData = @Html.Raw(JsonConvert.SerializeObject(Model));

   $(function() {

   vm = new BookViewModel(@Html.Raw(initialData));


    ws = new XSockets.WebSocket("ws://"); 

    //Just write to the console on open
    ws.bind(XSockets.Events.open, function(client) {
        console.log('OPEN', client);

        ws.bind('SendBook', function (msg) {


        ws.bind(XSockets.Events.onError, function (err) {
            console.log('ERROR', err);
The Knockout.js ViewModel is as follows
var BookViewModel = function(data) {

//this.Books = ko.observableArray(data);
this.Books = ko.observableArray(ko.utils.arrayMap(data, function(book) {
    return new BookItem(book);

this.AddOrUpdate = function(book) { 
               this.Books.push(new BookItem(book));       
I would appreciate any help

Jun 22, 2014 at 7:44 AM

You try to render the table at the client side, but grid.mvc renders table at the server side.

You need to create an Knockout template for rendering grid, and you don't need to use Grid.Mvc in your approach