$('#mustGetID').combogrid({
panelWidth:500,
panelHeight:250,
url: '<?= $url; ?>get_item.php',
queryParams: {
id_item: row.id_item
},
idField:'id_item',
textField:'name_item',
mode:'remote',
fitColumns:true,
nowrap: false,
columns:[[
{field:'id_item',title:'id_item',width:100},
{field:'name_item',title:'name_item',width:200}
]]
,onSelect: function(index,row){
alert($(this).attr('id');
}
});
我如何获取ID 警报的属性名称($(this).attr(&#39; id&#39;); 应该是 mustGetID ,任何人请帮忙
答案 0 :(得分:0)
尝试此$(row).attr('id)
,因为选择将返回该元素和元素的索引
答案 1 :(得分:0)
this
指的是调用它的对象。这意味着this
将引用您单击的行。换句话说,你无法轻易得到你想要的东西。如果唯一的目的是获取combogrid元素的id,我建议将元素的id存储在变量中,并将其保存在onSelect的范围内,以便您可以访问它。像,
var $el = 'mustGetID';
$('#' + $el).combogrid({
panelWidth:500,
panelHeight:250,
url: '<?= $url; ?>get_item.php',
queryParams: {
id_item: row.id_item
},
idField:'id_item',
textField:'name_item',
mode:'remote',
fitColumns:true,
nowrap: false,
columns:[[
{field:'id_item',title:'id_item',width:100},
{field:'name_item',title:'name_item',width:200}
]]
,onSelect: function(index,row){
alert($el);
}
});