如何使select 2在create jtable模式下工作。我有选择2在模态的时刻,但我不能写搜索... 外部纳税人:{ title:'test',create:true,编辑:false,list:true,//设置为true,启用列表视图listClass中的列:'select2-init',inputClass:'select 2-init',选项:{ 1:“Avalara”,0:“Nenhum”},//在列中添加一个CSS类,display:function(data){ var html =““;
html += "</select></div>";
return html;
},
input: function (data) {
if (data.formType === 'create') {
var html = "<div class=\"span3\"> <select id=\"subProductsListDDL\" name=\"ExternalTaxProvider\">";;
// Add options or logic for create form here
// For example: You can add option elements inside the select element
return html;
} else {
// Add options or logic for edit form here
// Example: You can get the current value with data.value
return data.record.ExternalTaxProvider;
}
}
},
},
formCreated: function (event, data) {
// Initialize the Select2 input for the "ExternalTaxProvider" field in the create/edit form
if (data.formType === 'create' || data.formType === 'edit') {
// Find the existing input element for "ExternalTaxProvider"
var $originalInput = data.form.find('[name="ExternalTaxProvider"]');
// Replace the original input with the $input (Select2-enhanced) element
initSelect2ForExternalTaxProvider();
// Initialize the Select2 for the "ExternalTaxProvider" field
$originalInput.select2({
placeholder: 'Test',
minimumInputLength: 1,
data: [
{ id: 1, text: 'Option 1' },
{ id: 2, text: 'Option 2' },
{ id: 3, text: 'Option 3' },
// Add more options as needed
]
});
}
},
});
This is what I have! the data is just for testing because o not know what is the problem...
thank you :)
3条答案
按热度按时间dpiehjr41#
我没有使用jTable,但我认为可以在加载时使用jtalbe回调函数。
字符串
3df52oht2#
我会将select2更改放在recordsLoaded回调函数中,而不是load方法回调函数中。将其放置在那里,代码将在load、reload、addRecord和updateRecord时被调用。
4zcjmb1e3#
如何使select 2在create jtable模式下工作。我有选择2在模态的时刻,但我不能写搜索...
外部纳税人:{ title:'test',create:true,编辑:false,list:true,//设置为true,启用列表视图listClass中的列:'select2-init',inputClass:'select 2-init',选项:{ 1:“Avalara”,0:“Nenhum”},//在列中添加一个CSS类,display:function(data){ var html =““;
字符串