Solved

Clear model and reload with data from json call.

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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