ユーザーがチェックボックスのリストを選択するjqグリッドがあり、コントローラーに送信したい
JavaScript 関数で選択したビューを取得しています
私は次の方法で試しました
- スクリプトで変数を作成し、それをアクションに渡そうとしましたが機能しませんでした
- ビューバッグで試してみましたが機能しませんでした
- モデルにプロパティを追加してみました 関数からリストに値を追加する 機能しませんでした
ここに私のスクリプトが表示されています
function ChangeStatusSource() {
//checking if any records are selected or not
var type= StatusRecords();
if (type=="@Resources.Strings.NoRecordsSelected") {
return;
}
//checking if any records are selected or not END
var id = '';
$.each($("input[id^='chkOF_']"), function (index, ctrl) {
if ($(ctrl).is(':checked')) {
id += $(ctrl).val() + ',';
}
});
OpenPopup('@Url.Action("FileUpload",new { i need to pass here})', gridReloadSourceField);
}
ここにコントローラーのアクションがあります
public ActionResult FileUpload( i need to get the list values)
{
List<string> sourceId = ViewBag.Id;
LoggingManager.Enter();
var res = new SourceFieldModel { FieldID = null};
LoggingManager.Exit();
return View(res);
}
ビューはjqgridにあり、ビューは次のとおりです。
$(document).ready(function () {
$("a.button").button();
var url = '@Url.Action("ListAll")' + '?s_partId=' + '@ViewBag.SourceId';
var colNames = ['<input type="checkbox" onclick="CheckAll(this.checked,\'chkOF_\',event);" name="checkall">',
'Edit',
'Ignore',
'Field/Role',
'Terms',
'Field Type'];
var colModel = [
{ name: 'Id', index: 'Id', align: 'center', formatter: checkFormatter, width: 20 },
{ name: 'Edit', index: 'Id', align: 'center', formatter: myCustomSourceFormatter, width: 60 },
{ name: 'Ignore', index: 'Ignore', align: 'center', formatter: dcheckFormatter, width: 100 },
{ name: 'FieldName', index: 'FieldName', align: 'left', width: 190 },
{ name: 'Term', index: 'Term', align: 'left' },
{name: 'FieldType',index:'FieldType', align:'left', width:200}
];
チェックボックスの値を追加するためのカスタムフォーマッター:
var myCustomSourceFormatter = function (cellvalue, options, rowObject) {
$("cellvalue").val(cellvalue);
var data = 1;
var returnValue = "<input style='height:27px;' id='buttonedit' type='button' value='Edit' onclick=javascript:SourceFieldEdit('" + cellvalue + "') />";
return returnValue;
};