我有一個表與一些數據來。其中一列是持有年份信息的組合框。當點擊該行時,它會自動選擇。但是,當我更改年份組合時,選擇消失(這是正常的)。我希望每當組合更改時再次選擇行。雙擊功能和組合更改功能放置如下:jquery datatables row_selected類添加到一行
$("#rulesTable tbody").click(function(event) {
$(rulesTableGlobal.fnSettings().aoData).each(function(){
$(this.nTr).removeClass('row_selected');
});
$(event.target.parentNode).addClass('row_selected');
var row = getSelectedRowIndex(rulesTableGlobal);
var selectedYear = $('#comboYear'+ row +' option:selected').text();
var propertyId = rulesTableGlobal.fnGetData()[row][0];
$('#calendarFrame').attr('src', "propertyTariffCalendar.php?ref="+propertyId+"&year="+selectedYear);
updateDescription(row, selectedYear);
});
//組合更改,與我所有的嘗試嘗試。他們中沒有一個是將類添加到行中。
$("#comboYear"+rowNo).change(function() {
var comboId = $(this).attr('id');
var comboIndex = $(this).attr('name');
var propertyId = rulesTableGlobal.fnGetData()[comboIndex][0];
var yearSelected = $('#'+comboId+' option:selected').text();
//alert(comboId + "-" + comboIndex+ "-" + yearSelected+ "-" +propertyId);
$.fn.upDateRow (propertyId, yearSelected, comboIndex);
$('#calendarFrame').attr('src', "propertyTariffCalendar.php?ref="+propertyId+"&year="+yearSelected);
updateDescription(rowNo, yearSelected);
/*var orjRow = $(this);
var row = orjRow.closest("tr").get(0);
$().addClass("row_selected");
*/
var orjRow = $("#comboYear"+rowNo);
//orjRow.parent().parent().addClass("row_selected");
//alert($(this).closest("tr").attr('id'));
//$('td:eq(0)', nRow).addClass('highloadRow');
//$(this).parent().parent().parent().addClass('row_selected');
//$(this).closest('tr').get(0).addClass('row_selected');
//$(this).closest('tr').addClass('row_selected');
//$(this).closest('td').closest('tr').addClass('row_selected');
//alert($(this).closest("tr").parent());
//$(this).closest("tr").get(0).addClass("row_selected");
//$(this).closest("tr").addClass("row_selected");
//$(event.target.parentNode).addClass('row_selected');
});
是的這是一個。我會檢查你的答案,以及我會寫我的答案,遭受同樣的問題。感謝一百萬! – user403295 2011-03-28 06:03:11