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

  • Home
  • SEARCH
  • 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 7923673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:23:56+00:00 2026-06-03T17:23:56+00:00

I am using jqGrid and want to know the best solution to implement it.

  • 0

I am using jqGrid and want to know the best solution to implement it. I am using backbone and jQuery. Following are the feature required

  1. Columns with Hyperlink. It will be Edit/Delete/Custom hyperlinks.
  2. On click on link, basically it should not navigate just call some function. For example, on delete it will just delete the row.
  3. Number of hyperlink columns are dynamic.

Hyperlink can be done in two ways

1) Use showlink formatter or Customer formatter. Problem with showlink is we can call only global functions and i am not comfortable writing my click event logic in loadComplete function. Because my grid is re-usable and dont know the number of columns i will be having hyperlink. So i am using custom formatter like this

deleteLinkFmatter : function(cellvalue, options, rowObject)
{
   return '<a onclick="deleteRow(' + options.rowId + ')">'+ cellvalue + '</a>';
}

Problem with the above code is, in backbone.js its saying that deleteRow not found. I found different ways suggested in this site but all in vain. Can any one suggest a solution?

  • 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-06-03T17:23:57+00:00Added an answer on June 3, 2026 at 5:23 pm

    I agree that the predefined formatter showlink is oriented on hyperlink and it’s not comfortable in case when you need to start your custom JavaScript function on click on the link. Nevertheless in the answer you would find the code which explain how you can use showlink in the case.

    If you want to add Edit/Delete/Custom hyperlinks in separate columns you can easy use dynamicLink which I wrote and described here. You are right, if you write that the function which you call in onclick attribute of <a> must be defined on the global level. You should not forget, that one can use some common global namespace like jQuery and define many functions which can be called from the jQuerynamespace. For example dynamicLink which you can download from here can be used in the same way as showlink. For example

    { name: 'editlink', formatter: 'dynamicLink',
        formatoptions: {
            onClick: function (rowid, iRow, iCol, cellText, e) {
                // any your code
            }
        }}
    

    In the implementation the method $.fn.fmatter.dynamicLink.onClick from the dynamicLink will be used in the onclick attribute.

    If you prefer to use unobtrusive JavaScript style I would recommend you to read the following answers: this, this and this with the corresponding demos this, this and this. Alternatively you can use doInEachRow which simplify a little the enumeration

    loadComplete: function() {
        var iCol = getColumnIndexByName.call(this, 'editlink'); // get index of the column
    
        $(this).jqGrid('doInEachRow', function (row, rowId, localRowData) {
            $(row.cells[iCol]).children("a").click(function (e) {
                e.preventDefault();
                // any your code here
            });
        });
    }
    

    where

    var getColumnIndexByName = function (columnName) {
            var $this = $(this), cm = $this.jqGrid('getGridParam', 'colModel'), i,
                l = cm.length;
    
            for (i = 0; i < l; i++) {
                if (cm[i].name === columnName) {
                    return i; // return the index
                }
            }
            return -1;
        };
    

    You can easy modify the above code for the case if you place many <a> hyperlinks in one column. In the case you can just replace .children("a") part of $(row.cells[iCol]).children("a").click(function (e) { to .children("a").eq(0) or .children("a").eq(1) and .children("a").eq(2) to define binding to the first, second or third hyperlink (“edit”/”add”/”delete”). You should better to save $(row.cells[iCol]).children("a") in a variable and use .eq(1) with the variable.

    One more way will be don’t define any <a> an all and use for example <span> instead (with underlining decoration or with background image). In the case you don’t need to suppress default hyperlink action and the click event will be bubble till the <table> element which define the grid body. So you can use onCellSelect or beforeSelectRow events to bind your JavaScript code. The Event (e parameter) of the events can be used to get all information about the clicked row and column. var $cell = $(e.target).closest('td') will get you the clicked cell, var $row = $cell.closest('tr.jqgrow') will get you the clicked row, $row.attr('id') will be the rowid and var iCol = $.jgrid.getCellIndex($cell[0]) get you the column index. The this.p.colModel[iCol].name is the name of the column which was clicked. You can read here more bout the way.

    How you can see you have really many options which you can use. So you can choose the way which better corresponds your requirements.

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

Sidebar

Related Questions

I'm using jQuery Expander plugin inside of a jqGrid column. I want to set
I'm using jqgrid tree grid with the following configuration colModel : [ { name:'id',width
I am using JQGrid control. It is very powerful and feature rich. Now I
I am using JQGrid Advance Search feature multipleSearch: true, multipleGroup: true . I am
I'm using jqgrid to display a list of sites and I want to do
I am using jqGrid to render some data. Now I want the ability to
I am using jqGrid 3.6.4 and a jquery 1.4.2 . in my sample i
I am using a jqGrid that has allot of columns to it. I added
I am using the jQuery layout plugin and the jqGrid plugin in one of
hi i am using jqgrid and want to do something like if i set

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.