過去数日間のほとんどを、ExtJS3で記述されたアプリケーションをExtJS4に変換する方法の調査に費やしました。残念ながら、APIドキュメントで、ExtJS4には次のメソッド/イベントが存在しないことがわかりました。 cellclick、getColumnModel()。
そうは言っても、削除するグリッド内の行を選択するためにチェックボックス選択モデルを使用しているグリッドパネルがあります。期待どおりに機能しますが、問題は、存在しない「cellclick」イベントをキャプチャする必要があるリンク(a href)を含むセルがグリッドにあることです。したがって、グリッドパネルに「itemclick」イベントを使用できることに気付きましたが、問題は、このイベントパラメータがグリッドの行にのみ関係することです。
列インデックスも必要なので、すべてのリンク(ahref)を含む列で「itemclick」イベントが発生したかどうかを判断できます。発生した場合は、次に何が発生するかを処理します。
これが私がExtJS4に変換しようとしているコードです
cellclick: function(grid,rowIndex,colIndex,e) {
if (colIndex == 3) {
var rec = grid.getStore().getAt(rowIndex);
var fieldname = grid.getColumnModel().getDataIndex(colIndex + 1);
var filename = rec.get(fieldname);
if (!filename) return;
var download_iframe = Ext.getCmp("report-download");
if (!download_iframe) {
download_iframe = document.createElement('iframe');
download_iframe.id = 'report-download';
download_iframe.style.display = 'none';
download_iframe.height = '100';
download_iframe.width = '600';
document.body.appendChild(download_iframe);
download_iframe.src = script to download file
} else {
download_iframe.src = script to download file
}
e.stopEvent();
}
}
これをExtJS4に変換することはできましたが、「itemclick」イベントが発生したセルをチェックする機能であるコードの1つの主要な部分が欠落しています。
Ext JS 4バージョン:
this.control({
'casereportGridPanel sgrid': {
itemclick: this.downloadReport,
selectionchange: this.toggleDelReportsBtn
},
.
.
.
.
}
downloadReport: function(view, record, item, rowIndex, e) {
var filename = record.data.file_name;
if (filename) {
if (!filename) return;
var download_iframe = this.getDownloadContainer();
if (!download_iframe) {
download_iframe = document.createElement('iframe');
download_iframe.id = 'downloadReportContainer';
download_iframe.style.display = 'none';
download_iframe.height = '100';
download_iframe.width = '600';
document.body.appendChild(download_iframe);
download_iframe.src = script to download file
} else {
download_iframe.src = script to download file
}
e.stopEvent();
}
},
グリッド構成:
{
xtype: 'sgrid',
autoScroll: true,
border: true,
columnLines: true,
id: 'myreportsgrid',
loadMask: true,
minHeight: 100,
selModel: Ext.create('Ext.selection.CheckboxModel',{checkOnly: true}),
plugins: [{
ptype: 'rowexpander',
rowBodyTpl: [
'<div style="border: 1px solid #CFCFCF; margin-left: 48px; padding: 0 0 8px 0;">',
'<div style="border: 0px solid #000; font-weight: bold; margin-left: 5px; padding: 5px 0 5px 5px; width: 200px;"><u>' + _t("case.report.grid.rowexpander.title") + '</u></div>',
'<table border="0" style="border-color: #666; margin-left: 5px; width: 575px;">',
'<tbody>',
'<tr>',
'<td style="border-color: #666; font-weight: bold; text-align: right; vertical-align: bottom; width: 75px;">' + _t("case.report.grid.rowexpander.casestatus") + ':</td>',
'<td style="border-color: #666; padding-left: 3px; vertical-align: bottom; width: 60px;">{case_status}</td>',
'<td style="border-color: #666; font-weight: bold; text-align: right; vertical-align: bottom; width: 70px;">' + _t("case.report.grid.rowexpander.startdate") + ':</td>',
'<td style="border-color: #666; padding-left: 3px; vertical-align: bottom;">{start_date}</td>',
'</tr>',
'<tr>',
'<td style="border-color: #666; font-weight: bold; text-align: right; vertical-align: bottom;">' + _t("case.report.grid.rowexpander.systemid") + ':</td>',
'<td style="border-color: #666; padding-left: 3px; vertical-align: bottom;">{system_ids}</td>',
'<td style="border-color: #666; font-weight: bold; text-align: right; vertical-align: bottom;">' + _t("case.report.grid.rowexpander.enddate") + ':</td>',
'<td style="border-color: #666; padding-left: 3px; vertical-align: bottom;">{end_date}</td>',
'</tr>',
'<tr>',
'<td style="border-color: #666; font-weight: bold; text-align: right; vertical-align: bottom;">' + _t("case.report.grid.rowexpander.parties") + ':</td>',
'<td style="border-color: #666; padding-left: 3px; vertical-align: bottom;" colspan="3">{parties}</td>',
'<tr>',
'</tbody>',
'</table>',
'</div>'
]
}],
store: 'CaseReports',
columns: [
{
dataIndex: 'id',
hidden: true,
renderer: this.renderText,
sortable: true,
text: _t('case.report.grid.id'),
width: 30
}, {
dataIndex: 'report_name',
flex: 1,
sortable: true,
text: _t('case.report.grid.reportName')
}, {
dataIndex: 'file_name',
hidden: true,
sortable: true,
text: _t('case.report.grid.filename'),
width: 200
}, {
dataIndex: 'date_requested',
renderer: this.renderDate,
sortable: true,
text: _t('case.report.grid.requested'),
width: 195
}, {
dataIndex: 'report_status',
renderer: this.renderText,
sortable: true,
text: _t('case.report.grid.reportStatus'),
width: 80
}
],
emptyText: '<div style="font-size: 11px; font-weight: bold; padding: 5px 0px; text-align: center;">' + _t('case.report.grid.noreports.available') + '</div>',
dockedItems: [{
xtype: 'toolbar',
items: [{
disabled: true,
action: 'deleteReport',
icon: SC.Url.image('delete.gif'),
text: _t('case.report.grid.deleteReports.btn'),
tooltip: _t('case.report.grid.deleteReports.btn.tooltip')
}, '->', { // begin using the right-justified button container
iconCls: 'x-tbar-loading',
action: 'refresh',
tooltip: _t('case.report.grid.refresh.tooltip')
}]
}]
Ext JS 4でこの作業を行う方法について誰かが光を当てるのを手伝ってくれたら、とてもありがたいです。
よろしくお願いします、
ショーン