jQuery UI Widgets › Forums › Grid › combobox with grid
Tagged: combobox, data, editor, grid, initeditor, jqxComboBox, jqxgrid, source
This topic contains 5 replies, has 2 voices, and was last updated by Dimitar 11 years, 3 months ago.
-
Authorcombobox with grid Posts
-
Hi,
How to clear the combo-box data when it is in grid please tell meRegards,
Bhanu.vHello Bhanu.v,
Do you wish to re-set the source of the combobox editor? If so, this can be done in the initeditor callback function.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi,
What you said is working perfectly but combo-box showing before selected values first, after 2 seconds they are showing re-set values.Regards,
Bhanu.vHi Bhanu.v,
Please post a sample code so that we can test your scenario locally. Remember to format the code by selecting it and clicking the
code
button in the toolbar.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Hi,
My code is this
$(“#IngestGrid”).jqxGrid(
{
width: ‘99.5%’,
source: source,
// pageable: true,
height: 550,
theme: ‘arctic’,
sortable: true,
altrows: true,
enabletooltips: true,
columnsresize: true,
columnsreorder: true,
////editmode: ‘programmatic’,
localization: getLocalization(),
//selectionmode: ‘singlecell’,
selectionmode: ‘multiplecellsadvanced’,
editable: true,
handlekeyboardnavigation: function (event) {
var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;if (key == 27) {
return true;
}
},columns: [
///Customer
{
text: ‘Customer’, datafield: ‘Customer’, width: ‘12%’, columntype: ‘combobox’,
cellbeginedit: Customer_cellbeginedit,
createeditor: CreateEditorForCustomer1,
initeditor: initeditorforCustomer,
geteditorvalue: Customer_GetEditorValue},
///Title
{
text: ‘Title’, datafield: ‘Title’, width: ‘12%’, columntype: ‘combobox’, sortable: false,
cellbeginedit: Title_cellbeginedit,
createeditor: CreateEditorForTitle1,
initeditor: initeditorforTitle1,
geteditorvalue: Title_GetEditorValue}
});
function initeditorforCustomer(row, column, editor) {
_editingRowIndex = row;if ($(“#IngestGrid”).jqxGrid(‘getrowdata’, _editingRowIndex) != undefined) {
if ($(“#IngestGrid”).jqxGrid(‘getrowdata’, _editingRowIndex).CustomerMetaData.PKCustomerID <= 0) {
var _editorValue = editor.val();
console.log(_editorValue);
if (_editorValue != undefined && _editorValue.length > 2) {
editor.val(”);
console.log(editor.value);
}
}
}
}var isChanged = false;
var _increment = 0;function CreateEditorForCustomer1(row, column, editor) {
// assign a new data source to the dropdownlist.
//_editingRowIndex = row;editor.jqxComboBox({
//autoDropDownHeight: true,
dropDownHeight: ‘211px’,
source: _customersDataAdapter,
//source: [],
displayMember: ‘XytechCustomerName’,
valueMember: ‘PKCustomerID’,
searchMode: ‘startswithignorecase’,
enableSelection: true,
enableHover: true,
//autoDropDownHeight: true,
showArrow: false,
//autoComplete:true,
remoteAutoComplete: true,
dropDownHorizontalAlignment: ‘left’,
openDelay: ’50’,
renderSelectedItem: function (index, item) {var item = _customersDataAdapter.records[index];
if (item != null) {var label = item.XytechCustomerName;
return label;
}
return “”;
},
search: function (searchString) {
_customersDataAdapter.dataBind();
}
});
editor.on(“change”, function (event) {
_pKCustomerID = editor.val();
var _selectedCustomer = null;
if ($.type(_pKCustomerID) == “number”) {_selectedCustomer = editor.jqxComboBox(‘getSelectedItem’);//.originalItem
console.log(_selectedCustomer.label);
//editor.jqxComboBox(‘focus’);
AssignCustomerMetaData1(_selectedCustomer);
if (_increment != 0) {
$(“#comboboxeditorIngestGridCustomer”).jqxComboBox(‘val’, _selectedCustomer.label);}
_increment++;
//GetCustomerTitles(_pKCustomerID, null);
//return _selectedCustomer.label;
}});
editor.on(‘open’, function (event) {
var _selectedIndex = editor.jqxComboBox(“selectedIndex”);// $(“#” + event.currentTarget.id).jqxComboBox(‘getSelectedIndex’);
//editor.jqxComboBox(‘dropDownHeight’,’100′);
if (_selectedIndex != undefined && _selectedIndex >= 0) {//$(“#” + event.currentTarget.id).jqxComboBox(‘selectIndex’, _selectedIndex);
//$(“#” + event.currentTarget.id).jqxComboBox(‘ensureVisible’, _selectedIndex);
//$(“#” + event.currentTarget.id).jqxComboBox(‘focus’);}
});
}var Customer_cellbeginedit = function (row, datafield, columntype, value) {
$(‘#IngestGrid’).jqxGrid(‘setcolumnproperty’, datafield, ‘width’, ‘12%’);if (value == undefined) {
if (_customersDataAdapter._options.data != undefined) {_customersDataAdapter._options.data.query = “”;
_customersDataAdapter.loadedData = [];if ($(“#comboboxeditorIngestGridCustomer”).length > 0) {
$(“#comboboxeditorIngestGridCustomer”).jqxComboBox(‘searchString’, ”);
//alert(‘height’);
//$(“#comboboxeditorIngestGridCustomer”).jqxComboBox(‘dropDownHeight’, ‘100px’);
_customersDataAdapter.dataBind();
}
}
}
else {
if (_customersDataAdapter._options.data != undefined) {
_customersDataAdapter._options.data.query = value;
if ($(“#comboboxeditorIngestGridCustomer”).length > 0) {
//$(“#comboboxeditorIngestGridCustomer”).jqxComboBox(‘searchString’, value);
console.log(value);
//$(“#comboboxeditorIngestGridCustomer”).jqxComboBox({ dropDownHeight: ‘100px’ });_customersDataAdapter.dataBind();
}
}
}
}function CreateEditorForTitle1(row, column, editor) {
// assign a new data source to the dropdownlist.
_editingRowIndex = row;editor.jqxComboBox({ //autoDropDownHeight: true,
dropDownHeight: ‘250px’, displayMember: ‘FeatureSeriesTitle’, valueMember: ‘PKTitleID’, searchMode: ‘containsignorecase’, autoOpen: true,
autoComplete: true //enableSelection: true, enableHover: true,
});
editor.on(“change”, function (event) {
var titleId = editor.val();
if ($.type(titleId) == “number”) {
var _selectedItem = editor.jqxComboBox(‘getSelectedItem’);//.originalItem
$(“#comboboxeditorIngestGridTitle”).jqxComboBox(‘val’, _selectedItem.label);
AssignTitleMetaData2(_selectedItem);
isChanged = true;
}
});
editor.on(“close”, function (event) {//var _editingRow = $(“#IngestGrid”).jqxGrid(“getrowdata”, _editingRowIndex);
//var bgcolor = $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(9)”).css(“background-color”);
////var bgcolor1 = $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(8)”).css(“background-color”);
//var t = $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(8)”).text();//if (t == “”) {
// var titleId = editor.val();
// var _editingRow = $(“#IngestGrid”).jqxGrid(“getrowdata”, _editingRowIndex);
// if (_editingRow.EpisodeTitle == null) {
// var _isEmpty = true;
// }
// _editingRow.EpisodeNumber = null;
// _editingRow.EpisodeTitle = null;
// if ($.type(titleId) == “number”) {
// var _selectedItem = editor.jqxComboBox(‘getSelectedItem’);//.originalItem
// $(“#comboboxeditorIngestGridTitle”).jqxComboBox(‘val’, _selectedItem.label);
// }
// $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(9)”).text(”);
// $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(8)”).text(”);
// if (!_isEmpty && isChanged) {
// $(“#IngestGrid”).jqxGrid(‘updaterow’, _editingRowIndex, _editingRow);
// isChanged = false;
// }
// //$(‘#IngestGrid’).jqxGrid(‘updating’);
// //$(“#IngestGrid”).jqxGrid(“updating”);
//}
});
}
function initeditorforTitle1(row, column, editor) {
_editingRowIndex = row;var editingRow = $(“#IngestGrid”).jqxGrid(“getrowdata”, _editingRowIndex);
if (editingRow != null && editingRow.CustomerMetaData.PKCustomerID != undefined) {
if (editingRow.CustomerMetaData.PKCustomerID != 0) {
_pKCustomerID = editingRow.CustomerMetaData.PKCustomerID;
//console.log(editor.val() + “,” + editingRow.Title);
editor.val(”);
if (editingRow.Title == undefined) {editor.val(”);
setTimeout(function () {
$(“#comboboxeditorIngestGridTitle”).jqxComboBox(‘val’, ”);
}, 500);
}
if ($.type(editor.val()) != “number”) {
editor.val(”);
}//GetCustomerTitles(_pKCustomerID, null, editor);
AssignTitlesToEditor();
}
else {
editor.jqxComboBox({ source: [] });
}
}
else {
editor.jqxComboBox({ source: [] });
}
}
function Customer_GetEditorValue(row, cellvalue, editor) {
_editingRowIndex = row;if (editor.jqxComboBox(‘getSelectedItem’) != null) {
return editor.jqxComboBox(‘getSelectedItem’).label;
}
else if (cellvalue == $(“#IngestGrid”).jqxGrid(“getrowdata”, row).CustomerMetaData.XytechCompanyName) {
return cellvalue;
}
else {
return “”;
}
}function Title_GetEditorValue(row, cellvalue, editor) {
_editingRowIndex = row;var _editingRow = $(“#IngestGrid”).jqxGrid(“getrowdata”, _editingRowIndex);
if (editor.jqxComboBox(‘getSelectedItem’) != null) {
//return editor.jqxComboBox(‘selectedIndex’, -1);
var _editingRow = $(“#IngestGrid”).jqxGrid(“getrowdata”, _editingRowIndex);
//var bgcolor = $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(9)”).css(“background-color”);//if (bgcolor == “rgb(128, 128, 128)”) {
// if (_editingRow.EpisodeTitle == null) {
// var _isEmpty = true;
// _editingRow.EpisodeNumber = null;
// _editingRow.EpisodeTitle = null;
// }
//}
if (_editingRow.TitleMetaData.TitleType == “Feature”)
{
$(“#IngestGrid”).jqxGrid(‘setcellvalue’, row, “EpisodeTitle”, ” “);
$(“#IngestGrid”).jqxGrid(‘setcellvalue’, row, “EpisodeNumber”, null);
}
console.log(_editingRow.TitleMetaData.TitleType);
return editor.jqxComboBox(‘getSelectedItem’).label;
}
else {//if (_editingRow.TitleMetaData.TitleType == “Feature”) {
// editor.value = ”;
// editor.val() = ”;
// _editingRow.EpisodeNumber = null;
// _editingRow.EpisodeTitle = null;
// $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(9)”).text(”);
// $(“#row” + _editingRow.uid + “IngestGrid div:nth-child(8)”).text(”);
// // $(“#comboboxeditorIngestGridEpisodeTitle”).jqxComboBox({ source: null});
// $(“#IngestGrid”).jqxGrid(‘setcellvalue’, row, “EpisodeTitle”, ” “);
// $(“#IngestGrid”).jqxGrid(‘setcellvalue’, row, “EpisodeNumber”, ” “);// return;
//}if (cellvalue == $(“#IngestGrid”).jqxGrid(“getrowdata”, row).Title)
{
// return editor.val();
return cellvalue;
}
else {
return “”;
}
}}
var Title_cellbeginedit = function (row, datafield, columntype, value) {_editingRowIndex = row;
$(‘#IngestGrid’).jqxGrid(‘setcolumnproperty’, datafield, ‘width’, ‘20%’);
var _editingRow = $(“#IngestGrid”).jqxGrid(‘getrowdata’, row);if (_editingRow.Customer == undefined) {
value = “”;
ShowErrorNotifyMessage(‘Please select Customer…’);
return false;
}
else if (_editingRow.Customer.trim().length == 0) {
value = “”;
ShowErrorNotifyMessage(‘Please select Customer…’);
return false;
}if (_editingRow.CustomerMetaData.PKCustomerID != 0) {
value = “”;
_pKCustomerID = _editingRow.CustomerMetaData.PKCustomerID;
GetCustomerTitles(_pKCustomerID, null, null);//$(“#comboboxeditorIngestGridTitle”).jqxComboBox(‘searchString’, value);
}
}
Regards,
Bhanu.vHi Bhanu.v,
Please re-post your code and format it by selecting it and clicking the
code
button (betweenli
andclose tags
) in the toolbar.Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.