Solved

Clear model and reload with data from json call.

Posted on 2014-01-28
1
470 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
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

821 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