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 8066283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:56:09+00:00 2026-06-05T11:56:09+00:00

I am trying to make a cell colored and clickable if it satisfies certain

  • 0

I am trying to make a cell colored and clickable if it satisfies certain condition.
The problem that I am getting is in passing the parameter to the onclick of the element.
I am doing something like:

{
    name: 'numberOfUnits',
    index: 'numberOfUnits',
    sorttype: 'integer',
    cellattr: function (rowId, tv, rawObject, cm, rdata) {
        if (...) {
            return 'style="background-color:red" onClick="javascript:showReceivedLockedPieChartDialog(' + '\'' + lockedCellId + '\'' + ')"';
        }
        else {
            return 'style="color:black"';
        }
    }
}

I see that the text is being formed as:

style="background-color:red" onClick="javascript:showReceivedLockedPieChartDialog('ABC')"

I see that it is creating something like this…

<td aria-describedby="reportGrid_numberOfUnits" title="13" ABC")"="" onclick="javascript:showReceivedLockedPieChartDialog(" style="background-color:red" role="gridcell">13</td>

Please help me pass the parameter to this function.

  • 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-05T11:56:10+00:00Added an answer on June 5, 2026 at 11:56 am

    Ohh yes! Your code shows that the parting of string returned from cellattr will be parsed not carefully enough. I find that one should better rewrite the function formatCol which will be used internally. I wanted to post next time to trirand suggestion to change the code using RegEx matching.

    Nevertheless there are some simple rules which could allow to use cellattr in the current implementation:

    • you should use style attribute as the last attribute in the string returned from cellattr
    • you should include additional ' ' blank as the first character of returned value if you returns not only the value for the style attribute.
    • you should not use words style, title and class only as the names of the corresponding attributes.

    The last rule means that you should not use class="mytitle" or title="my class style". The parsing of the returned string is not so careful. So such names will have some side effects. As I wrote before the corresponding part of the code jqGrid which parse the results should be changed in my opinion. I will try to post the corresponding suggestions to trirand in the next time.

    In your case you should rewrite the code of cellattr to

    cellattr: function (rowId, tv, rawObject, cm, rdata) {
        if (...) {
            return ' onclick="showReceivedLockedPieChartDialog(' + '\'' +
                lockedCellId + '\'' + ')" style="background-color:red"';
        } else {
            return 'style="color:black"';
        }
    }
    

    The demo shows that the changes works.

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

Sidebar

Related Questions

Hey everbody, im getting a curious problem here. Im trying to make my table
I am trying to make an entire table cell clickable. The general advice I
I'm trying to make a UITableView that when a user selects a cell it
I am trying to make it so that when i select a cell in
I am trying to make a table cell that when tapped calls a phone
Trying to make a custom :confirm message for a rails form that returns data
Trying to make simple minesweeper game in python, but have one problem. I have
Trying to make a toggle button that hides/shows the right window/pane. Here is a
I'm trying to make the cells of a QTableView look like 3D clickable buttons.
As the title says, I'm trying to make a cell for each row a

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.