1 つのモデルで 2 つのテーブルをレンダリングしようとしています。ヘルパー dll を使用してテーブルを作成しています。問題は、ページの最初の呼び出しでビューデータの一部のみをレンダリングする方法がわからないことです。ここにいくつかのコードがあります:
コントローラー: (2 つのテーブルとビューデータを作成し、ビューを返し、モデルのビューデータを使用)
public class Controller1 : Controller {
//some code
public ActionResult Steuertabellen()
{
table = table_fill();
table= Tabelle.tabelleGenerieren(
table,
new Dictionary<string, SortierRichtung>(),
new List<string>(),
new List<string>()
);
table2 = table_fill();
table2 = Tabelle.tabelleGenerieren(
table2,
new Dictionary<string, SortierRichtung>(),
new List<string>()
);
VD_Planung_Prognosen viewdata = new VD_Planung_Prognosen();
viewdata.table= table;
viewdata.table2= table2;
return view(viewdata);
}
意見:
@model namespace.Models.VD_Planung_Prognosen
@using namespace.Models;
<div class="tabelle_partialview" id="tabelle_partialview_@(tabellen2ID)">@{Html.RenderPartial("PV_table2", Model);}</div>
<div id="optionen_tabelle">
<div id="optionen_rechts">
<button class="btn_speichern btn_speichern_@(tabellenID)" id="btn_speichern">Speichern</button>
<button class="btn_abbrechen btn_abbrechen_@(tabellenID)" id="btn_abbrechen_@(tabellenID)">Abbrechen</button>
</div>
</div>
<div class="tabelle_partialview" id="tabelle_partialview_@(tabellenID)">@{Html.RenderPartial("PV_table", Model);}
PartialViews (編集済み):
@model namespace.Models.VD_Planung_Prognosen
@using HelperLib_Html.Tabelle.v1_02;
@{
@Html.createTabelle(Model.tabel1)
}
//<some style>
編集 モデルを追加しました(おそらく以前にそれを行うべきでした)
モデル:
public class VD_Planung_Prognosen
{
public Matrix matrix { get; set; }
public Tabelle table1{ get; set; }
public Tabelle table2{ get; set; }
public List<stored_procedure1> years{ get; set; }
public List<stored_procedure2> groups{ get; set; }
public List<stored_procedure3> cost{ get; set; }
public List<stored_procedure4> costs2{ get; set; }
public List<stored_procedure5> data{ get; set; }
public int year{ get; set; }
public string grp{ get; set; }
public bool pflegeSteuertabellen { get; set; }
}
上記の actionlink に示されているデータは 1 つのモデルで示されているため、2 つのテーブルが相互に続き、renderpartial では 1 つが表示され、次にボタンが表示され、次に 2 つ目が表示されるため、これは機能しません。1 つのテーブルのみに対応できるようにモデルを使用するにはどうすればよいですか?
私の質問が理解できることを願っています。説明するのはかなり複雑です;)
前もって感謝します
ダニエル
Edit1: もちろん、PV もコントローラーで作成されます。ActionLink ビューと非常によく似ています。