-1

I have a div in MVC view which has a webgrid binded to a model. On initial page load the gird is perfectly populated by Model data but when I click the button on the same page the grid should be be updated by search values which is not happening. The grid is having same initial data even after button click. How should I refresh grid with updated values?

@{ var gd=new WebGrid(Model.NonPromoJobList,canPage:true,rowsPerPage:5,canSort:true, selectionFieldName:"selectedRow",ajaxUpdateContainerId:"gridContent");

   gd.Pager(WebGridPagerModes.NextPrevious);

}

 <div id="gridContent" class="container-fluid">
@gd.GetHtml(
        columns: gd.Columns(

        gd.Column("JobTitle", "Job Title",format: 
        @<text><a href="javascript:void()" onclick="javascript:showJobNotice('@item.JASEQ');" title="Job Title"> @Html.Raw(item.JOBTITLE) </a> </text>),
        gd.Column("Department","Department"),
        gd.Column("Location","Location"),
        gd.Column("ClosingDate","Closing Date"),
        gd.Column("Action",style:"col1",format: @<text>
     <a class="btn btn-xs btn-info" title="Apply Online" onclick="javascript:openApp('@item.JOBTITLESEQ');"  href="javascript:void()">Apply</a>

</text>
 )))
</div>

<div class="panel-footer text-center color4 ">
                <input type="button" class="btn btn-primary btn-s" value="Search" onclick="searchJobs()" />
</div>
jrummell
  • 42,637
  • 17
  • 112
  • 171
user8811
  • 75
  • 1
  • 2
  • 12
  • You either need to add a form so that you can submit the page back to the server, or add some javascript and use ajax. – jrummell Sep 25 '14 at 18:51

1 Answers1

0

You can do this with JQuery and the use of partial views. On the event fire a JQuery Ajax call to your MVC Action. The action can then return the partial view you want updated. Then in on the ajax success function in jquery just replace the HTML content of the partial view with the updated content that was returned by your action.

Gjohn
  • 1,261
  • 1
  • 8
  • 12