1

So basically I have a form with browser filters for data I'm displaying. I was hoping I could simply perform a post to my "SearchPost" controller, which handles all of the incoming filters and then spits out a Jquery grid for output, but unfortunately I haven't been able to find a free Jquery grid view that works.

That said, I'm still using an Ajax Post to perform the data query, but in turn I'd like to render a partial view that would have that data passed back from the "SearchPost" controller action to my "DataOutput" controller action.

Example:

This is my Ajax Call:

 $.ajax(
     {
     type: "POST",
     url: "/TFS/SearchPost",
     data: $("#myform").serialize(),

     success: function () {
         $("#showresults").load("/TFS/DataOutput");
         },

      error: function (req, status, error) {
         alert("Sorry! We could not receive your feedback at this time.");
         }
      });

In turn, that calls this controller action that would query my data and generate my output list / grid somehow:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SearchPost(TFS_mysearch tfs)
{

    List<Msg> TFSData = (from z in _DB.Msg.Take(10) select z).ToList();

    return ????       
}

And then the "Success" portion of my Ajax post would call the second controller action which would render my partial view containing the results. That make sense??

public ActionResult DataOutput(List<String> mylist) {

    return PartialView("DataOutput", mylist);

}

If anyone has an easy method to render my list data output to Json so that I could do it directly within my ajax, I could do that too, but figured that making use of a partial view might be cleaner.

3 Answers 3

1

So basically you don't want SearchPost returning a view, but data?

Maybe you want:

public ActionResult SearchPost(TFS_mysearch tfs)
{

    List<Msg> TFSData = (from z in _DB.Msg.Take(10) select z).ToList();

    return DataOutput(TFSData);      
}
public ActionResult DataOutput(List<String> mylist) {

    return PartialView("DataOutput", mylist);

}

except that the TFSData is a list of Msg's and DataOutput wants a list of strings. If you can reconsile that, then the above will work.

Sign up to request clarification or add additional context in comments.

2 Comments

What you describe above is what I need in theory, but can you call an controller "actionresult" from within another "actionresult".... when trying to experiment with this, the initial "return Dataoutput();" call gives me an error indicating "FormTest.Controllers.HomeController.Dataoutput(FormTest.Models.DataList)' is a 'method' but is used like a 'type'
I tried using a "RedirectToaction" and pass the data, but because I'm performing the post via Ajax and want to return a partial view, not sure this will work...
1

i would suggest client side templates:

http://weblogs.asp.net/dwahlin/archive/2009/05/03/using-jquery-with-client-side-data-binding-templates.aspx

Comments

0

How about:

[AcceptVerbs(HttpVerbs.Post)]
public JsonResult SearchPost(TFS_mysearch tfs)
{

    List<Msg> TFSData = (from z in _DB.Msg.Take(10) select z).ToList();

    return this.Json(TFSData);       
}

Have a look at this blog post for a fuller example.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.