複数の jqGrid を含むページがありますが、一度に表示できるのは 1 つだけです。いつでも見えるものを返す単純な関数が必要です。次のような関数があり、どの div が表示されているかを示します。
$('div').each(function(){
if($(this).is(':visible')){
alert($(this).attr('id'));
}
});
ページ上のすべてのjqGridを解析できるこのようなものはありますか?
ありがとう!
複数の jqGrid を含むページがありますが、一度に表示できるのは 1 つだけです。いつでも見えるものを返す単純な関数が必要です。次のような関数があり、どの div が表示されているかを示します。
$('div').each(function(){
if($(this).is(':visible')){
alert($(this).attr('id'));
}
});
ページ上のすべてのjqGridを解析できるこのようなものはありますか?
ありがとう!
おそらく次のようなものが必要です
$("table.ui-jqgrid-btable:visible").attr('id');
テーブルにグリッドがない場合は、undefined値が得られます。複数のグリッドが表示されている場合は、最初のグリッドの ID を取得します。
すべての可視グリッドの ID の配列を取得するには、次のコードを使用できます
var ids = $.map($("table.ui-jqgrid-btable:visible"), function(value) {
return value.id;
});
// now we have all ids in the array
alert(ids.join()); // display all as comma-separated
gridexpandosのテストを使用して、上記のコードをより安全にすることができます。
var ids = $.map($("table.ui-jqgrid-btable:visible"), function(value) {
if (value.grid) { return value.id; }
});
// now we have all ids in the array
alert(ids.join()); // display all as comma-separated
私が見た限りでは、すべてのグリッドはdivクラスでラップされていui-jqgridます。だから、以下のようなものを試してください、
$('div.ui-jqgrid:visible').each(function () {
alert(this.id); //above would return the gview_<table_id> or gbox_<table_id> or
//something_<table_id>
alert($(this).find('.ui-jqgrid-btable').attr('id')); //should return table_id
});