Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Clear model and reload with data from json call.

Posted on 2014-01-28
1
Medium Priority
?
474 Views
Last Modified: 2014-02-01
My question is how do I get the rows in the array ‘data’ into the model?

Given:
@model IEnumerable<MyModel.Domain.Entities.SearchResult>
@using MvcJqGrid;
@using MvcJqGrid.Enums;
….a lot of html for titles and tabs and buttons of all sorts.
Then there is this grid

@if(Model.Any())
{

//http://www.coldfusion-ria.com/Test/KSPersonal/jQuery/gridtest1.cfm

   @(Html.Grid("myGrid").OnSelectRow("onRowSelected(rowid, status)")
    .SetCaption(@Session["ResultsForDescription"].ToString())
    .AddColumn(new Column("ColumnName1"))
    .AddColumn(new Column("ColumnName2"").SetLabel("Col #"))
    …
    .SetAutoWidth(true)
    .SetRowNum(10)
    .SetRowList(new[] { 10, 25, 50, 100 })
    .SetViewRecords(true)
    .SetPager("pager")
    .SetSearchToolbar(true)
    .SetSearchOnEnter(false).SetAltRows(true).SetAltClass("myAltRowClass")
    .SetSearchClearButton(true)
    .SetSearchToggleButton(true))

The grid correctly loads with the model data.  Hurray!

Then I try to reload the grid based on some user input.  I do with this call.

function JsonSubmit(btnName) {
$.getJSON('../Home/JsonIndex', { btnName: "buttonSubmitName", time: new Date() }, function (data) {
             debugger;
             $.each(data, function (i, oneRow) {
             });
         });
     }
The variable ‘data’ contains the correct data and the variable ‘oneRow’ is correct.
 I need to do something like
@Model.Clear();
@Model = data;

Thank you for your time and suggestions.
0
Comment
Question by:wilfordrocks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
wilfordrocks earned 0 total points
ID: 39827022
I will close the question.  In the end I  posted back to the server and reloaded the entire view.  slow, ugly but functional.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question