带有MVC4控制器的JQuery AppendGrid

时间:2014-03-13 10:44:54

标签: jquery asp.net-mvc-4 controller grid

我们如何在Visual Studio MVC4解决方案中集成AppendGrid控件?

问题是我无法使用@ Html.EditorFor,因为appendgrid控件是自动构造的。

在以下尝试中,过滤器始终为空。

我猜可能有两种解决方案。

  1. 管理将包含网格的序列化字符串传递给控制器​​(我尝试做但不起作用) 或
  2. 使用标准的Html.BeginForm @ Html.EditorFor技术

  3. [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>
    

0 个答案:

没有答案