This is a migrated thread and some comments may be shown as answers.

[Solved] Not Made ajax request

0 Answers 20 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
nitendra
Top achievements
Rank 1
nitendra asked on 20 Apr 2011, 08:50 AM
hi
Telerik team,

I have to use your asp.net mvc extension (Grid Control)

in this control i wish to  use ajax binding.
so i follow all instruction (how to  make ajax binding)
but if i am click on pagination any link  (1 2 3...) my page is post back.
i am not finding what the problem on my code,
so please check it and tell me what is the  miss on my code file.

1) master page -
<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>
 
<%@ Register src="../Views/Shared/Link.ascx" tagname="Link" tagprefix="uc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title>
    <asp:ContentPlaceHolder ID="TitleContent" runat="server" />
         
    </title>
    <link href="Layout.css" rel="stylesheet" type="text/css" />
    <link href="Module.css" rel="stylesheet" type="text/css" />
    <link href="Grid.css" rel="stylesheet" type="text/css" />
</head>
<body>
 
    <form id="form1" runat="server">
 
    <div id="container">
    <div id ="header">Header Here<img src="/Content/img/brand/jobseeker/HeaderLogo.gif" />
    <div><%= Html.ActionLink("User", "FirstLook", "Grid")%>      
    <%= Html.ActionLink("Home","Index","Home") %>     
    <%= Html.ActionLink("PostJob", "PostJob", "Home")%>
    </div></div>
    <div id="wrapper1">
        <div id="wrapper2">
            <div id="maincol">
                <div id="leftcol">
                <div id="LeftBarLink">
                <div align="center" >
                    <img src="/Content/Images/poweredby.gif" />
                </div>
                </div>
                    <uc1:Link ID="Link1" runat="server" />
                </div>
                <div id="centercolNoRightBar">
                <asp:ContentPlaceHolder ID="MainContent" runat="server">
         
                </asp:ContentPlaceHolder>
                </div>
            </div>
     
            <div id="footer"> footer here </div>
        </div>
    </div>
         
    </div>
    </form>
 
       
</body>
</html>

 2) View Page-

<%@ Page Title="" Language="C#" MasterPageFile="~/Content/Home.Master"
Inherits="System.Web.Mvc.ViewPage<IEnumerable<ITClassifieds.Models.User>>" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 
    <h2>User</h2>
 
    <br />
 
     <%= Html.Telerik().Grid(Model)
        .Name("Grid")
        .DataKeys(keys => keys.Add(o => o.UserID))
        .Columns(columns =>
        {
            columns.Bound(o => o.Firstname).Width(100);
            columns.Bound(o => o.Lastname).Width(200);
            columns.Bound(o => o.EmailAddress).Width(200);
            columns.Bound(o => o.DBSource).Width(120);
            //columns.Command(commands =>
            //{
            //    commands.Edit();
            //    commands.Delete();
            //}).Width(200);
 
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Server().Select("FirstLook", "Grid", new
            {
                ajax =
                    ViewData["ajax"]
            });
                //.Insert("Insert", "Grid")
                //.Update("Save", "Grid")
                //.Delete("Delete", "Grid");
 
            dataBinding.Ajax().Select("_FirstLook",
                "Grid").Enabled((bool)ViewData["ajax"]);
                //.Insert("Insert", "Grid")
                //.Update("Save", "Grid")
                //.Delete("Delete", "Grid");  
                        
        })
        .Scrollable(scrolling => scrolling.Enabled((bool)ViewData["scrolling"]))
        .Sortable(sorting => sorting.Enabled((bool)ViewData["sorting"]))
        .Pageable(paging => paging.Enabled((bool)ViewData["paging"]))
        .Filterable(filtering => filtering.Enabled((bool)ViewData["filtering"]))
        .Groupable(grouping => grouping.Enabled((bool)ViewData["grouping"]))
        .Footer((bool)ViewData["showFooter"])
             
%>
 
</asp:Content>


3) Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ITClassifieds.Models;
using Telerik.Web.Mvc;
 
namespace ITClassifieds.Controllers
{
    public partial class GridController : Controller
    {
        //
        // GET: /Grid/
 
        public ActionResult FirstLook()
        {
            ViewData["ajax"] =  true;
            ViewData["scrolling"] =  true;
            ViewData["paging"] =  true;
            ViewData["filtering"] =  true;
            ViewData["grouping"] =  true;
            ViewData["sorting"] = true;
            ViewData["showFooter"] =  true;
            return View(GetAllProduct());
             
        }
 
        [GridAction]
        public ActionResult _FirstLook()
        {            
            return View(new GridModel( GetAllProduct()));
        }
 
    }
}
Tags
Grid
Asked by
nitendra
Top achievements
Rank 1
Share this question
or