Note that there are some explanatory texts on larger screens.

plurals
  1. POAsp.net MVC WebGrid in partial view not updating through Ajax
    primarykey
    data
    text
    <p>I have 2 WebGrids each in a different partial view, displaying on a View Page. All is working fine but when I do sorting or pagination on WebGrid, it's not updating through ajax. What am I doing wrong?</p> <p><strong>PartialView1</strong>:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;IEnumerable&lt;CRMEvent.Models.CRM.DatabaseEntities.CRM_Request&gt;&gt;" %&gt; &lt;% var grid1var = new WebGrid(source: Model, defaultSort: "Id", fieldNamePrefix: "grid1", canSort: true, ajaxUpdateContainerId: "Div1", canPage: true, rowsPerPage: 5);%&gt; &lt;div id="Div1"&gt; &lt;%=grid1var.GetHtml(htmlAttributes: new { id = "grid1" }, tableStyle: "GridTable", headerStyle: "GridHeader", footerStyle: "GridFooter", columns: grid1var.Columns( grid1var.Column(columnName: "Id", header: "ID", canSort: true), grid1var.Column(columnName: "Request_For_Id", header: "Request For", canSort: true), grid1var.Column(columnName: "Date_Created", header: "Date", canSort: true, format: item =&gt; item.Date_Created.ToString("dd-MM-yyyy")) ))%&gt; &lt;/div&gt; </code></pre> <p><strong>PartialView2</strong></p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;IEnumerable&lt;CRMEvent.Models.CRM.DatabaseEntities.CRM_Request&gt;&gt;" %&gt; &lt;% var grid2var = new WebGrid(source: Model, defaultSort: "Id", fieldNamePrefix: "grid2", canSort: true, ajaxUpdateContainerId: "Div2", canPage: true, rowsPerPage: 5);%&gt; &lt;div id="Div2"&gt; &lt;%=grid2var.GetHtml(htmlAttributes: new { id = "grid2" }, tableStyle: "GridTable", headerStyle: "GridHeader", footerStyle: "GridFooter", columns: grid2var.Columns( grid2var.Column(columnName: "Id", header: "ID", canSort: true), grid2var.Column(columnName: "Request_For_Id", header: "Request For", canSort: true), grid2var.Column(columnName: "Date_Created", header: "Date", canSort: true, format: item =&gt; item.Date_Created.ToString("dd-MM-yyyy")) ))%&gt; &lt;/div&gt; </code></pre> <p><strong>MainPage:</strong></p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;CRMEvent.Models.CRM.DatabaseEntities.CRM_Request&gt;" %&gt; &lt;asp:Content ID="Head" ContentPlaceHolderID="HeadContent" runat="server"&gt; &lt;link href="../../Content/Styles/Dashboard.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;%using (Html.BeginForm("Action", "Dashboard", FormMethod.Post)){ %&gt; &lt;div id="MainDashboardDiv"&gt; &lt;div class="LiveTile"&gt; &lt;div id="PriorityDiv1"&gt; &lt;%Html.RenderAction("RecentRequests", Model); %&gt; &lt;/div&gt; &lt;!--End of PriorityDiv1 --&gt; &lt;div id="PriorityDiv2"&gt; &lt;%Html.RenderAction("PriorityRequests", Model); %&gt; &lt;/div&gt; &lt;!--End of PriorityDiv2 --&gt; &lt;/div&gt; &lt;!--End of LiveTile --&gt; &lt;/div&gt;&lt;!--End of MainDashboardDiv --&gt; &lt;%} %&gt; &lt;/asp:Content&gt; </code></pre> <p><strong>Master page HEAD tag content:</strong></p> <pre><code>&lt;head id="head" runat="server"&gt; &lt;title&gt;&lt;asp:ContentPlaceHolder ID="TitleContent" runat="server" /&gt;&lt;/title&gt; &lt;link href="../../Content/Site.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="&lt;%: Url.Content("~/Scripts/jquery-1.9.1.min.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="&lt;%: Url.Content("~/Scripts/modernizr-1.7.min.js") %&gt;" type="text/javascript"&gt;&lt;/script&gt; &lt;asp:ContentPlaceholder ID="HeadContent" runat="server"&gt; &lt;/asp:ContentPlaceholder&gt; &lt;link href="../../Content/menu.css" rel="stylesheet" type="text/css" /&gt; &lt;script src="../../Scripts/jquery.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="../../Scripts/menu.js" type="text/javascript"&gt;&lt;/script&gt; &lt;/head&gt; </code></pre> <p>Also when I check console through firebug, I saw an error while I do sorting and pagination: Error is:</p> <blockquote> <p>TypeError: $(...).parent(...).delegate is not a function</p> </blockquote> <p>on code:</p> <blockquote> <p>$(containerId).parent().delegate(containerId + ' a[data-swhglnk="true"]', 'click', function()</p> </blockquote> <p>Above code is generated by WebGrid dynamically. I am not writing it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload