locked
JQGrid in Dynamic Data Site RRS feed

  • Question

  • User1037441716 posted

    Hi ,

    I want to implement Jqgrid(Jquery Grid) in place of gridview in dynamic data site.Can anyone send me the source code.I am facing problem in implementing jqGrid in List.aspx page.Please reply asap.

    Thanx In advance.

    Wednesday, April 8, 2015 7:28 AM

All replies

  • User-330204900 posted

    Hi Sp91, the source code for what?

    Wednesday, April 8, 2015 7:59 AM
  • User1037441716 posted

    how to implement jggrid for list.aspx page

    Wednesday, April 8, 2015 8:22 AM
  • User-330204900 posted

    As far as I know there is not a working version of jQuery grid for Dynamic Data sorry.

    Wednesday, April 8, 2015 8:27 AM
  • User1037441716 posted

    I am working on it.Default.aspx page is working fine by Jqgrid

    Wednesday, April 8, 2015 8:37 AM
  • User1711366110 posted

    I am working on it.Default.aspx page is working fine by Jqgrid

      you meant that Default.aspx is working fine by jqgrid ,but its not working in List.aspx when you implementing it ?
    If yes, Please post your corresponding code & explain your issues briefly .
    Thanks for understanding.
    --
    with regards,
    Edwin

    Thursday, April 9, 2015 1:36 AM
  • User1037441716 posted

    Default.aspx

    ---------------------

    <script src="JqGrid/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="JqGrid/jquery.jqGrid.src.js" type="text/javascript"></script>
    <script src="JqGrid/grid.locale-en.js" type="text/javascript"></script>
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" />
    <h2 class="DDSubHeader">My tables</h2>
    <table id="grid" style= "width:100%"></table>
    <div id="pager"></div>
    <br /><br />
    <script type="text/javascript">
    function Link(id) {
    var row = id.split("=");
    var row_ID = row[1];
    var sitename = $("#grid").getCell(row_ID, 'Name');
    // var url = "http://"+sitename+"/List.aspx"; // sitename will be like google.com or yahoo.com
    var url = "http://"+"localhost:52299/" +sitename+ "/List.aspx";
    // window.open(url);
    // window.open("http://localhost:52299/Default.aspx")
    // window.open("http://localhost:52299/CIS_APPLICATION_CODE/List.aspx")
    window.open(url);
    }
    </script>
    <script type="text/javascript">
    $(document).ready(function () {
    $("#grid").jqGrid({
    type: "POST",
    url: "Handler1.ashx",
    datatype: "json",
    colNames: ["TableName"],
    colModel:
    [
    { name: 'Name', index: 'Name', width: 100,formatter: 'showlink',formatoptions: { baseLinkUrl: 'javascript:', showAction: "Link('", addParam: "');" }}
    ],
    rowNum: 6,
    rowList: [6],
    loadonce: true,
    pager: '#pager',
    sortorder: "asc",
    height: "auto",
    width: "1350",
    viewrecords: true
    });
    });
    </script>
    </asp:Content>

    Dfault.aspx.cs

    ----------------

    using System;
    using System.ComponentModel.DataAnnotations;
    using System.Web.DynamicData;
    using System.Web;
    using System.Web.Services;
    using System.Web.Script.Services;
    using System.Collections;
    using System.Collections.Generic;
    using System.Web.UI.WebControls;


    namespace DynamicData
    {
    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }


    }
    }

    I am using Helper Class for getting data for my JQgrid

    Handlet.ashx.cs

    ------------------------

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Script.Serialization;

    namespace DynamicData
    {
    /// <summary>
    /// Summary description for Handler1
    /// </summary>
    public class Handler1 : IHttpHandler
    {

    public void ProcessRequest(HttpContext context)
    {
    HttpRequest request = context.Request;
    HttpResponse response = context.Response;

    string _search = request["_search"];
    //string numberofRows = request["rowNum"];
    string numberOfRows = request["rows"];
    //string pageIndex = request["rowList"];
    string pageIndex = request["page"];
    //string sortColumnName = request["sidx"];
    string sortOrderBy = request["sord"];
    //string sortOrderBy = request["sortorder"];


    //List<TableName> users = GetUsers(numberOfRows, pageIndex, sortColumnName, sortOrderBy, out totalRecords);
    string output = BuildJQGridResults( Convert.ToInt32(numberOfRows), Convert.ToInt32(pageIndex));
    response.Write(output);

    }

    public bool IsReusable
    {
    get
    {
    return false;
    }
    }

    private string BuildJQGridResults(int numberOfRows, int pageIndex)
    {


    System.Collections.IList visibleTables = Global.DefaultModel.VisibleTables;
    List<TableName> tableList = new List<TableName>();
    for (int i = 0; i < visibleTables.Count; i++)
    {
    TableName obj = new TableName(visibleTables[i].ToString());

    tableList.Add(obj);


    }


    DynamicData.TableName.JQGridResults result = new DynamicData.TableName.JQGridResults();
    List<DynamicData.TableName.JQGridRow> rows = new List<DynamicData.TableName.JQGridRow>();
    DynamicData.TableName.JQGridRow row = new DynamicData.TableName.JQGridRow();
    //row.id = 0;
    int rowID = 0;
    foreach (TableName tableName in tableList)
    {
    //DynamicData.TableName.JQGridRow row = new DynamicData.TableName.JQGridRow();
    row.id = rowID+1;
    //row.id += 1;
    row.cell = new string[10];
    row.cell[0] = tableName.Name;
    rows.Add(row);
    rowID = rowID + 1;
    }
    result.rows = rows.ToArray();
    result.page = pageIndex;
    //result.total = totalRecords / numberOfRows;
    result.records = 100;
    return new JavaScriptSerializer().Serialize(result);
    }
    }


    }

    I want to replace grid of List.aspx page with JqGrid

    Thursday, April 9, 2015 2:01 AM
  • User-330204900 posted

    I think you would need to write a server control that supports Dynamic Data and then implements jQuery Grid to get this working :) if you are doing it manually you may as well use scaffolding or MVC

    Thursday, April 9, 2015 4:49 AM