I have created one grid using jqWidget. I'm trying to put the drop-down list in the 7th column of jqxgrid. My code is as follows. I can't get the expected output.
// Data which I want to get in dropdownlist
var drpSource = [
{ id: 1, name: "Edit" },
{ id: 2, name: "SendMail" }
];
// This is particular 'column' part of my grid
columns: [
{ dataField: 'user_name', text: 'Username', },
{ dataField: 'first_name', text: 'First Name', },
{ dataField: 'last_name', text: 'Last Name', },
{ dataField: 'email', text: 'Email', width: 300 },
{ dataField: 'register_dt', text: 'Registered Date', cellsformat: 'MM/dd/yyyy', },
{ dataField: 'expiration_dt', text: 'Expiry Date', cellsformat: 'MM/dd/yyyy', },
{
width: 100, autoshowfiltericon: false, dataField: 'drpfunction', text: "Function", columntype: 'dropdownlist',
createeditor: function (row, cellvalue, editor) {
editor.jqxDropDownList({
source: drpSource,
displayMember: 'name',
valueMember: 'id',
filterable: false,
placeHolder: 'Choose…',
autoDropDownHeight: true
});
},
initeditor: function (row, cellvalue, editor) {
editor.jqxDropDownList('selectItem', cellvalue);
}
}
Am I missing anything?
Note: Column has been created successfully, Although it's blank.
You didn't mentioned what is your expected output and what error you received. I can't help you more without more info. Your code seems fine to me except you need to add
cellvaluechangingevent in order to change the id number displayed after you select the option injqxDropDownList.Also I think is good to mention that you need to double click the cell in column 7 in order to trigger the
jqxDropDownList.Example: https://jsfiddle.net/f0szowah/ (You need to modify it to fit your case!)
html code:
JavaScript + jQuery code: