Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7219041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:34:19+00:00 2026-05-28T21:34:19+00:00

I have read some topic regarding with my question but there code doesn’t work

  • 0

I have read some topic regarding with my question but there code doesn’t work for me. Honestly, I’m not good in jQuery.

I have this working views and controller, but it has a lot disadvantages that is why I switch to using jQuery grid.

Working code (not using jQuery grid):

@using Custom.Helpers
@model IEnumerable<Models.DeviceMVC>

@{
    ViewBag.Title = "List";
}

<div id="page-title">
<h2>Device list</h2>
    <div id="Optiontab">
        @Html.ActionLink("Create New", "Create")
    </div>
</div>
<table id="table-list">
    <tr>
        <th>
            Branch
        </th>
        <th>
            Name
        </th>
        <th>
            Login id
        </th>
        <th>
            Serial number
        </th>
        <th>
            Brand
        </th>
        <th>
            Model
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.BranchName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.LoginID)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.SerialNum)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Brand)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Model)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.DeviceID, branch = item.BranchName }) |
            @Html.ActionLink("Details", "Details", new { id=item.DeviceID })
        </td>
    </tr>
}
</table>  

To resolve the link in side areas, I use this helper:
Helper

To load data:

public ActionResult Index()
{
    IDeviceComponentMVC mvc = new DeviceComponentMVC();
    return View(mvc.RetrieveAllDevices());
}  

Now in jQuery (View part):

<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery("#list").jqGrid({
            url: '@Url.Content("~/Device/LoadDevice")',
            datatype: 'json',
            mtype: 'POST',
            colNames: ['Branch', 'Name', 'Username', 'Serial', 'Brand', 'Model'],
            colModel: [
          { name: 'Branch', index: 'Branch', width: 136, align: 'Branch', sortable: false },
          { name: 'Name', index: 'Name', width: 136, align: 'Name' },
          { name: 'LoginID', index: 'LoginID', width: 136, align: 'LoginID' },
          { name: 'SerialNum', index: 'SerialNum', width: 100, align: 'SerialNum' },
          { name: 'Brand', index: 'Brand', width: 136, align: 'Brand' },
          { name: 'Model', index: 'Model', width: 136, align: 'Model' }
          ],
            pager: jQuery('#pager'),
            rowNum: 5,
            rowList: [10, 50, 100, 150, 250, 300, 350, 400, 500],
            sortname: 'Name',
            sortorder: "desc",
            viewrecords: true,
            imgpath: '',
            caption: 'Device list'
        })
    });

</script>  
<table id="list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pager" class="scroll" style="text-align:center; padding:50px;"></div>  

Controller part:

public JsonResult LoadDevice(string sidx, string sord, int page, int rows)
{
    using (DBase db = new DBase())
    {
        var context = db;
        int pageIndex = Convert.ToInt32(page) - 1;
        int pageSize = rows;
        int totalRecords = context.devices.Count();
        int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);

        var devices = context.devices.OrderBy("it." + sidx + " " + sord).Skip(pageIndex * pageSize).Take(pageSize);

        var sorted = (from item in devices
                      select new
                      {
                          i = item.DeviceID,
                          cell = new List<string> { item.branch.Name, item.Name, item.LoginID, item.SerialNum, item.Brand, item.Model }
                      }).ToArray();

        var jsonData = new
        {
            total = totalPages,
            page,
            records = totalRecords,
            rows = sorted
        };
        return Json(jsonData);
    }
}  

Now my very goal is to put navigation buttons like this:

enter image description here

But these button should have specific link. The link like what my first view (without jQuery grid) does have.

Currently I have:

enter image description here

Hope someone could help. Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T21:34:20+00:00Added an answer on May 28, 2026 at 9:34 pm

    You miss one line in your script. Append this to your script, to make the last lines look like this:

           caption: 'Device list'
        }).navGrid("#pager, { add: false, edit: false, del: false }
    

    See http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator for all the details of this function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read the topic about pointer, but i still have some question. //
I have read a lot of topics here regarding xml and tried some, but
I have read questions and answers about this topic but I still have some
Ok, yes, I've read the other Qs regarding this topic, but I have several
I have read through some articles on this topic but I am still cautious
I have read some posts about this topic and the answers are comet, reverse
I have read some posts on here about not mixing parameters when passing into
I have read some articles on POCO in the enttity framework but still don't
I have read in some of the ClickOnce posts that ClickOnce does not allow
I have read from some article that say's Apple doesn't approve the application which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.