0
私はMVCとjqgridを使用していますので、ウィンドウを追加または編集するにはdropdownlistから値を渡す必要があります。これは私のコードです:jqgridウィンドウパラメータを追加
ビュー:
jQuery("#grid").jqGrid({
url: '@Url.Content("~/")' + 'Something/GridData/',
datatype: "json",
mtype: 'POST',
colNames: ['Type', 'Product', 'Value1', 'Value2', 'Value3'],
colModel: [
{ name: 'parType', index: 'parType', width: 80, align: 'center', sortable: false, editable: true, search: false,
editrules: { required: true, number: true },
editoptions: {
dataEvents: [{
type: 'keyup',
fn: function (e) {
if (this.value.match(/\D/)) this.value = this.value.replace(/\D/g, '');
}
}]
}
},
{ name: 'parProduct', index: 'parProduct', width: 80, align: 'left', editable: true, edittype: "select",
editrules: { required: true },
editoptions: {
multiple: false,
size: 1,
dataUrl: '@Url.Content("~/")' + 'Something/List/',
buildSelect: function (data) {
var response = jQuery.parseJSON(data);
var s = '<select>';
if (response && response.length) {
for (var i = 0, l = response.length; i < l; i++) {
var ri = response[i];
s += '<option value="' + ri.Value + '">' + ri.Text + '</option>';
}
}
return s + "</select>";
}
}
},
{ name: 'parValue1', index: 'parValue1', width: 80, align: 'right', sortable: false, editable: true, search: false,
editrules: { required: true, number: true },
editoptions: {
dataEvents: [{
type: 'keyup',
fn: function (e) {
if (this.value.match(/\D/)) this.value = this.value.replace(/\D/g, '');
}
}]
}
},
{ name: 'parValue2', index: 'parValue2', width: 80, align: 'right', sortable: false, editable: true, search: false,
editrules: { required: true, number: true },
editoptions: {
dataEvents: [{
type: 'keyup',
fn: function (e) {
if (this.value.match(/\D/)) this.value = this.value.replace(/\D/g, '');
}
}]
}
},
{ name: 'parValue3', index: "parValue3", width: 80, align: 'right', editable: true,
editrules: { required: true },
editoptions: {
dataEvents: [{
type: 'blur',
fn: function (e) {
onBlurDecimal(this.id);
}
}]
}
}],
rowNum: 10,
rowList: [10, 20, 30],
pager: jQuery('#pager'),
sortname: '',
viewrecords: true,
sortorder: "asc",
caption: "Title",
height: 250,
width: 700
});
jQuery("#grid").jqGrid('navGrid', '#pager',
{ edit: false, add: true, del: true, search: false }, //options
{url: '@Url.Content("~/")' + 'Something/Add', closeAfterAdd: true, width: 500 }, // add options
{} // search options
);
@Html.ValidationSummary(False)
@Using Html.BeginForm()
<table>
<tr>
<td>
@Html.Label("ID_CONTRATANTE", "Contratante:")
@Html.DropDownListFor(Function(Model) Model.ID_CONTRATANTE, Nothing, New With {.style = "width:300px; visibility:visible", .class = "letraingreso"})
</td>
</tr>
</table>
End Using
コントローラ
Function Add(ByVal parType As Long, ByVal parProduct As Long, ByVal parValue1 As Long, ByVal parValue2 As Long, ByVal parValue3 As String) As ActionResult
Try
Dim varE As General1Entities = New General1Entities
Dim parIDContratante = Request.Form("ID_CONTRATANTE")
Dim var1 = New OBJECT With { _
.ID_TYPE = parProduct,
.ID_CONTRATANTE = parIDContratante,
.CODE = parType,
.VALUE1 = parValue1,
.VALUE2 = parValue2,
.VALUE3 = parValue3
}
varE.AddToOBJECTS(var1)
varE.SaveChanges()
Return Json(True)
Catch ex As Exception
Return Json(False)
End Try
End Function
あなたが見ることができるように、私がメインビュー(ID_CONTRATANTE)からDDL値を取得し、それを配置する必要がありますparIDContratanteに入力します。明らかに値が返されるNothingこれはjqgridのウィンドウが開いているためです。この値をビューウィンドウに追加するには、どのように親ビューから送信できますか?
よろしくお願いいたします。