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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:23:40+00:00 2026-06-02T10:23:40+00:00

In Jqgrid you apply a required attribute to any given field like this {

  • 0

In Jqgrid you apply a required attribute to any given field like this

 { name: 'Comments', index: 'Comments', editable: true, editrules: { required: true }, edittype: 'textarea' }

How would I go about doing this dynamically?
I’d like to make a field required, based on another field (like the selected value of a dropdown/combobox)

I know where to place the code, eg, my dropdown’s select event. But not how to apply the required attribute in any other way other than the code sample I supplied..

  • 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-02T10:23:42+00:00Added an answer on June 2, 2026 at 10:23 am

    I suggest that you use some event to monitor the changes in the select control and change the value of the required option of editrules.

    For example in the demo I used ‘focusout’ event on the select control of ‘ship_via’ column to change the required option of editrules of the column ‘note’. I used the ‘focusout’ event because the code used the bug fix which I suggested here. You can use other events alternatively, but you should test there in different browsers.

    The code which I used in the demo is

    {name: 'ship_via', index: 'ship_via', width: 105, align: 'center', editable: true,
        formatter: 'select', edittype: 'select', editoptions: {
            value: 'FE:FedEx;TN:TNT;IN:Intim',
            defaultValue: 'IN',
            dataEvents: [
                {
                    type: 'focusout',
                    fn: function (e) {
                        $grid.jqGrid('setColProp', 'note', {
                            editrules: {required: ($(e.target).val() !== "IN")}
                        });
                    }
                }
            ]
        },
        stype: 'select', searchoptions: {
            sopt: ['eq', 'ne'],
            value: ':Any;FE:FedEx;TN:TNT;IN:IN'
        } },
    { name: 'note', index: 'note', width: 60, sortable: false, editable: true,
        edittype: 'textarea' }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does jqGrid just have any callback after single field search? The onSearch callback fires
I've setup a jqGrid like this $('#gridTable').jqGrid({ url: '/GridData/', ... Now if I navigate
I would like to manually apply searching to my jqGrid via JavaScript. I have
I've been having problems getting jqGrid to sort. I'd like to preferable do this
I'm using jqgrid tree grid with the following configuration colModel : [ { name:'id',width
I have a jqgrid with a subgrid. I am attempting to apply different colors
JQgrid outputs this html for a left aligned cell - but it is too
The jqGrid has been kicking my butt (as well as others on this site).
I am using jqgrid on EF4 MVC3 (C#). I based search on this @Oleg
Is there any way to apply a specific CSS class to all cells in

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.