我们如何在Visual Studio MVC4解决方案中集成AppendGrid控件?
问题是我无法使用@ Html.EditorFor,因为appendgrid控件是自动构造的。
在以下尝试中,过滤器始终为空。
我猜可能有两种解决方案。
[HttpPost]
public ActionResult NewFilter(string filter)
{
return RedirectToAction("Index");
}
@model Models.FilterModel
@{
ViewBag.Title = "New Filter";
}
<form id="frmMain" name="frmMain" method="post">
<fieldset>
<legend>New Filter</legend>
<table id="tblAppendGrid"></table>
</fieldset>
</form>
<script type="text/javascript">
$(document).ready(function () {
// Initialize appendGrid
$('#tblAppendGrid').appendGrid({
caption: 'Filters Collections',
initRows: 4,
columns: [
{ name: 'AttributeName', display: 'Attribute Name', type: 'text', ctrlAttr: { maxlength: 100 }, ctrlCss: { width: '160px'} },
{ name: 'Operation', display: 'Operation', type: 'select', ctrlOptions: { 0: 'Choose', 1: 'Equals', 2: 'DoesNotEqual', 3: 'Contains', 4: 'DoesNotContain', 5: 'StartsWith', 6: 'DoesNotStartWith', 7: 'MatchRegex', 8: 'DoesNotMatchRegex' }, ctrlAttr: { maxlength: 100 }, ctrlCss: { width: '100px'} },
{ name: 'AttributeValue', display: 'Attribute Value', type: 'text', ctrlAttr: { maxlength: 4 }, ctrlCss: { width: '160px'} }
],
hideButtons: {
moveUp: true,
moveDown: true
}
});
});
<script type="text/javascript">
$('#dialog_Save-button').button().click(function () {
var oData = $(document.forms[0]).serialize()
alert(oData);
$.ajax({
type: 'post',
url: "/configuration/NewFilter",
data: oData,
success: alert("Record UdpateSucessfully.")
});
});
</script>