2

MVC4 + EXT.NET ライブラリ プロジェクトで、GridPanel() 内の JsonReader() に応答する StoreResult コントローラーを作成します。私のコントローラーは、json データの代わりに文字列 Ext.Net.MVC.StoreResult を返します。VS2012、IIS8、MVC4でプロジェクトを作成しています。

助けてくれてありがとう。

// IN VIEW

@(Html.X().GridPanel()
.ID("GridPanel1")
.Title("Array Grid")
.Width(600)
.Height(350)
.Store(s => s.Add(Html.X().Store()
    .PageSize(100)
    .Buffered(true)
    .AutoLoad(false)
    .Proxy(proxy=>proxy.Add(Html.X().AjaxProxy()
        .Url("/Data/GetData")
        .Reader(reader=>reader.Add(Html.X().JsonReader()
            .Root("data")))
     ))
    .Model(model => model.Add(Html.X().Model()
    .Fields(field =>
    {
        field.Add(Html.X().ModelField().Name("UserId"));
        field.Add(Html.X().ModelField().Name("UserName"));


    })
    ))

))
.VerticalScroller(scroller => scroller.Add(Html.X().GridPagingScroller()))
    .ColumnModel(columnModel =>
    {
        columnModel.Columns.Add(Html.X().Column()
            .Text("UserId")
            .DataIndex("UserID")
            .Flex(1)
            .Width(70));
        columnModel.Columns.Add(Html.X().Column()
            .Text("UserName")
            .DataIndex("UserName")
            .Flex(1));
        columnModel.Columns.Add(Html.X().Column()
            .Text("UserPassword")
            .DataIndex("UserPassword")
            .Flex(1));        
    })
.View(view => view.Add(Html.X().GridView().TrackOver(false)))
.Listeners(listeners =>
{
    listeners.AfterRender.Handler = "this.store.guaranteeRange(0,99);";
    listeners.AfterRender.Delay = 100;
})
)

///////// IN CONTROLLER

    public class DataController : System.Web.Mvc.Controller
    {
        //
        // GET: /Data/GetData/
        public Ext.Net.MVC.StoreResult GetData(int page = 1, int start = 0, int limit = 100)
        {

            StoreResult responce = new StoreResult();


            List<UserList> UserList = new List<UserList>();

            for (int i = start + 1; i <= start + limit; i++)
            {
                UserList user = new UserList()
                    {
                        UserId = i,
                        UserName = "UserName " + i
                    };
                UserList.Add(user);
            }

            responce.Data = UserList;
            responce.Total = 50000;
            return responce;


        }


    }
4

1 に答える 1

1

これを変更してみてください

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.5.7" />
    <assemblyIdentity name="Ext.Net.Utilities" publicKeyToken="2c34ac34702a3c23" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0" newVersion="2.0.1" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

これに

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.5.7" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="Ext.Net.Utilities" publicKeyToken="2c34ac34702a3c23" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0" newVersion="2.0.1" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

あなたのweb.configファイルで。

于 2012-10-10T13:37:47.437 に答える