Solved

Clear model and reload with data from json call.

Posted on 2014-01-28
1
457 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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
This video discusses moving either the default database or any database to a new volume.

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now