Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Clear model and reload with data from json call.

Posted on 2014-01-28
1
Medium Priority
?
477 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

876 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