A.K
A.K

Reputation: 505

How to pass parameter to EditOptions DataURL method for edittype="select" for inline editing

I need to get different set of values in a dropdown column in jqGrid. I am using jqGrid 4.4.4

There are two parts of the problem

  1. How to pass a parameter to my DataURL method?

The column model

{ key: false, name: 'ContactName', index: 'ContactName', editable: true, width: '100px', sortable: false, frozen: true, formatter: 'select',  edittype: 'select',
                    editoptions: {

                        dataUrl: '/InvestorList/GetContactList'
                    }

And 2. How to populate the value in the cell when it is not in Editing mode? I am using inline editing.

Thanks,

Upvotes: 0

Views: 4248

Answers (1)

Oleg
Oleg

Reputation: 221997

If you use so old version than you have restricted possibilities, but I looks in the code of jqGrid 4.4.4. It have already one feature which you can use: you can use postData defined as function:

{ name: 'ContactName', editable: true, width: 100, sortable: false, frozen: true,
    formatter: 'select',  edittype: 'select',
    editoptions: {
        dataUrl: '/InvestorList/GetContactList',
        postData: function (rowid, value, cmName) {
            return {
                myId: rowid
            }
        }
    }
}

I removed in the definition of ContactName unneeded index property and fixed the value of width property from wrong value '100px' to 100. The value should be a number.

The above code add myId parameter with rowid to the request to '/InvestorList/GetContactList'.

To set the value of the cell, if the row is not in the inline/cell editing mode, you can use just setCell method.

Upvotes: 2

Related Questions