私の理解にはギャップがあります。私は 2 つのビュー画面を持っています。1 つは devexpress 選択グリッドから値を正常に取得しますが、もう 1 つはそうではありません...そして、自分が何を違う方法で行っているのか理解できません。
firebug を使用すると、モデルが DOM のどこに設定されているかわかりません。
以下の作品:
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations;
namespace EtracsWeb.Areas.IO.Models
{
public class VoyageInputModel
{
[Required(ErrorMessage = "Value must be supplied")]
[Display(Name = "Show Received Voyages")]
public bool ShowReceivedVoyages { get; set; }
public string VoyageIDS { get; set; }
}
}
ビューで使用されています(これは機能します)...ここにビューの断片があります:
@using EtracsWeb.Areas.IO.Models;
@model VoyageInputModel
@{
ViewBag.Title = "Voyage (Receive/UnReceive/etc..)";
Layout = "~/Views/Shared/_LayoutMenu.cshtml";
}
@* MUST go here and NOT at end or code won't work *@
<script type="text/javascript">
//This is the value from the devExpress Selection Grid...
function OnSelectionChanged(s, e) {
s.GetSelectedFieldValues("VoyageID", GetSelectedFieldValuesCallback);
}
//This is the value from the InputModel...notice it is different...
//This is why we need this two step process.
function GetSelectedFieldValuesCallback(values) {
// voyage_ids = values;
//alert(values);
document.getElementById('VoyageIDS').value = values;
//alert(document.getElementById('VoyageIDS').value)
}
</script>
OnSelection からの値を 1 つの変数として変更し、inputModel の設定を別の名前として取得していることに注意してください....これはすべて機能します...
私は 2 番目のビューでそれを実行しようとしていますが、getElementbyID を使用してモデル内の変数にアクセスしようとすると、コードが停止します。最初は int を使用しようとしていましたが、文字列に切り替えました。 ..しかし、どちらも機能しません....
モデルは DOM のどこにあるのでしょうか。Firebug を使用して (asp.net mvc から) @model 値を表示するにはどうすればよいですか?
2番目のウィンドウで間違ったアイデアはありますか?
2 番目の入力モデルは次のとおりです。
using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations;
namespace EtracsWeb.Areas.Vehicle.Models
{
public class BookMarkListInputModel
{
public string SelectedBookMarkID { get; set; }
public int BookMarkID { get; set; }
public IEnumerable<BookMark> BookMarks { get; set; }
}
}
および 2 番目のビュー フラグメント:
@using EtracsWeb.Areas.Vehicle.Models
@model BookMarkListInputModel
@{
ViewBag.Title = "List";
Layout = "~/Views/Shared/_LayoutMenu.cshtml";
}
@* MUST go here and NOT at end or code won't work *@
<script type="text/javascript">
//This is the value used in the DevExpress Selection Grid
function OnSelectionChanged(s, e) {
s.GetSelectedFieldValues("BookMarkID", GetSelectedFieldValuesCallback);
}
//This is the variable from the InputModel...notice it can be different
//So we need to have this two step process.
function GetSelectedFieldValuesCallback(values) {
alert(values);
document.getElementById('SelectedBookMarkID').value = values;
alert(document.getElementById('SelectedBookMarkID').value)
}
function Success(data) {
// alert(data.ReturnMessage);
id1.innerHTML = data.ReturnMessage;
}
</script>