Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
Disabling edit controls based on other edit controls
Tags: H
22/07/2010
16:49
Avatar
jqwha
Member
Members
Forum Posts: 18
Member Since:
07/07/2010
sp_UserOfflineSmall Offline

Hi,

If I have a grid where two of the columns are editable, one is a drop-down list and the other is a text box. Is it possible to enable/disable the textbox, based on value the user selects in the drop-down? i.e. the text box becomes editable only if they select "Yes" from the dropdown. It is not editable if they select "No".

I may end up using radio buttons instead of a dropdown but I'm sure the logic would be the same? (N.B. I may not be able to use radios because they don't work in the grid in IE6 which is, unfortunately, still one of our target browsers 🙁 )

Thanks!

22/07/2010
17:04
Avatar
williamfjordan
Member
Members
Forum Posts: 3
Member Since:
13/05/2010
sp_UserOfflineSmall Offline

I am doing a similar action based on a value from a select list in another cell.

My grid is in cell edit mode so your mileage may vary if you are in row edit mode.

I have a function in the beforeSaveCell event that checks if the cell being changed is the one with the dropdown.

Depending on the value selected I will enable / disable editing on 3 other cells in the same row.

To disable a cell from being editable, change the cssclass to 'not-editable-cell'.

To make it editable again, remove that class.

Example:

    function checkRQD(rowid, cellname, value, iRow, iCol) {
        //if not required, disallow editing of columns 4, 5, and 6
        if (cellname == 'RQD') {
            var cssclass = '';
            if (value == '4') {      //Not required
                cssclass = 'not-editable-cell';
            }
            var row = theGrid.getInd(rowid, true)
            row.cells[4].className = cssclass;
            row.cells[5].className = cssclass;
            row.cells[6].className = cssclass;
        }
    }

23/07/2010
11:43
Avatar
jqwha
Member
Members
Forum Posts: 18
Member Since:
07/07/2010
sp_UserOfflineSmall Offline

Hi,

I had a quick play around but couldn't get it to work exactly - I am using row-editing. I think I need to apply the class you mentioned to a "span" inside the cell to make it work. However, since I'm going to have to do some DOM navigation to do that any way, I wondered if there were a similar method that would give me more control in the future.

i.e. I'm experimenting with this: Say I have two columns, col1 has a pair of radios (Yes/No), col 2 has a dropdown list. I want to disable the dropdown if the user clicks radio "No", enable if "Yes"...

So I could apply a class to each radion/dropdown control (radio buttons have "classActionRadio", dropdownlists have "classActionDDL", etc). I use a jQuery.live call (on page startup) to ensure each radio control with "classActionRadio" has the attached event below (rough code):

        $(".classActionRadio").live('change', function(event) {
        //lastgridsel will be set to the rowid being edited
            if (lastgridsel) {
                var row = myGrid.getInd(lastgridsel, true)
                //Now, if the radio button "No" is selected...
                if (event.currentTarget.value == 'No') {
            //Do some jQuery magic to find the "next" dropdownlist in the DOM with "classActionDDL" and disable it.
                }
                else {
            //enable the DDL.
                }
            }
        });

Does that sound right? This is the bit where someone shows me the one line call that does it all 🙂 I feel like I'm making this too complicated.

Thanks. I'm looking forward to a time when I can ANSWER a question on here!

23/07/2010
11:50
Avatar
jqwha
Member
Members
Forum Posts: 18
Member Since:
07/07/2010
sp_UserOfflineSmall Offline

ooh. Just saw "dataEvents" in http://www.trirand.com/jqgridw.....mmon_rules

could this be it!? :-)

EDIT: Maybe not. Still doesn't help me to find the control that is to be disabled 🙁

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
32 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information