HTML レンダリングを使用して、mvc にレポート エンジンを実装しました。render メソッドによって返されたメタデータに基づいて、カスタム ページング機能を作成する必要がありました。私は現在、同じ方法でインタラクティブな並べ替えを実装することを検討していますが、これはより困難な作業のように見えます。HTML Device Information SettingsヘッダーにActionScriptという html レンダリング用の設定があるようです。
ActionScript(*) - ドリルスルーやブックマークのクリックなどのアクション イベントが発生したときに使用する JavaScript 関数の名前を指定します。このパラメータが指定されている場合、アクション イベントは、サーバーへのポストバックではなく、指定された JavaScript 関数をトリガーします。
私の質問は、誰かがこの機能を使用したことがありますか? レポートがレンダリングされた後に認証が失われるため、何らかの方法でコントローラーで認証済みのコールバックを作成する必要があります。レポートにソート用のパラメーターを追加するだけの方が簡単かもしれませんが、レポートでインタラクティブなソートを維持したいと思います。
--Solution1 の編集---
上記のスクリプト名の横にある * は、ssrs 2012 以降、ActionScript パラメーターが減価償却されていることを意味することがわかりました。したがって、私はそれを追求しないことにしました。他の誰かがこれに出くわした場合、ポストバックなしでインタラクティブな並べ替えをシミュレートするために私が考えた最良の方法を以下に詳しく説明します。
レポートについて
1. Add a parameter to the report SortField1
2. Add a Sort condition to the Tablix or group you wish to sort. Tablix-Sort Expressions
3. Set the expression of the sort to Fields(Paremeters!SortField1.Value).Value
4. Set the default value of parameter SortField1 to the default sort field
5. Set Allow Nulls of the parameter to true.
6. Add a image or label for each column you would like to sort by
7. Create a action for the element created in step 7 with code similar to
="javascript:void(reportSortRequest('ColumsFieldName'))"
NOTE: Your view or view descendant will have need to have an identical function defined to accept the action
ビューで
- 関数 reportSortRequest(fieldName) を実装します。これにより、Model.SortField1 が設定され、コントローラーへのポストが呼び出されて、レポートが再レンダリングされます。
コントローラー内 (これは、フィールド SortField1 を持つモデルを送信する Ajax ポストバック用です)
- SortField1 を含むレポート情報を使用してレンダリングを呼び出します。
レポート マークアップ ラッパーにアクセスするために機能するクライアント スクリプトで更新されました。
ssrs マークアップによって生成されたレポート要素には、タグによってビューでアクセスできます。私は、以下が所定の ssrs ラッパー要素#oReportCellを使用して機能することを発見しました":
iframe にロード:
var frameContent = $("#myIFrame").contents();
var ssrsContentElement = frameContent.find("#oReportCell");
div にロード:
var ssrsContentElement = $("#myDiv").find("#oReportCell");
html blob をフレームまたは div にロードする関数。レポートの構成方法に応じて、コンテンツは一時ファイルの URL または HTML マークアップのいずれかになります。
function setReportContent(content, isUrl, renderInIFrame) {
if (isUrl) {
if (renderInIFrame) {
$("#reportContent").html("<iframe id='reportFrame' sandbox='allow-same-origin allow-scripts' width='100%' height='300' scrolling='yes' onload='onReportFrameLoad();'\></iframe>");
$('#reportFrame').attr('src', content);
}
else
$("#reportContent").load(content);
}
else {
if (renderInIFrame) {
$("#reportContent").html("<iframe id='reportFrame' sandbox='allow-same-origin allow-scripts' width='100%' height='300' scrolling='yes' onload='onReportFrameLoad();'\></iframe>");
$('#reportFrame').contents().find('html').html(content);
}
else
$("#reportContent").html(content);
}
if(!renderInIFrame)
showReportWaitIndicator(false);
$("#reportContent").show();
}
allow-scripts
auto-resize プロパティが設定されたレポート画像を正しくレンダリングするには、ssrs resize js 関数が起動できるようにオンにする必要があることに注意してください。