0

In my view have this:

@{
 var properties = db.StylesPropertyDefs.OrderBy(o => o.PropertyId);
}

..
..
@(Html.X().GridPanel()
      .Title("Array Grid")
      .ID("propertyGrid")
      .Width(600)
      .Height(350)
      .Store(Html.X().Store()
                 .Model(Html.X().Model()
                            .Fields(
                                new ModelField("PropertyId", ModelFieldType.Int),
                                new ModelField("PropertyName", ModelFieldType.String),
                                new ModelField("PropertyShortName", ModelFieldType.String),
                                new ModelField("PropertyActiveFlag", ModelFieldType.Boolean)
                            )
                 ).DataSource(properties)
..
..

And i have an action in the controller to add new property. The new property is added successful but I can refresh the PanelGrid (without refresh the whole page). Here is the controller:

    [DirectMethod]
    public ActionResult AddNewProperty(string propertyName, string propertyCode, bool propertyActive)
                {
                    if (propertyName == "" || propertyCode=="")
                    {
                        X.Msg.Show(new MessageBoxConfig
                        {
                            Title = "Error",
                            Message = "The field name or code can not be empty.",
                            Buttons = MessageBox.Button.OK,
                            Icon = MessageBox.Icon.ERROR
                        });
                        return this.Direct();
                    }

    //if all is ok add new property
                    var newOne = new StylesPropertyDef
                        {
                            PropertyActiveFlag = propertyActive,
                            PropertyName = propertyName,
                            PropertyShortName = propertyCode
                        };
                    var db = new TaosKnowledgeDataContext(DataUtils.GetConStringLocal());
                    db.StylesPropertyDefs.InsertOnSubmit(newOne);
                    db.SubmitChanges();

    //reload properties
                    var properties = db.StylesPropertyDefs.OrderBy(o => o.PropertyId);

                    var theGrid = X.GetCmp<GridPanel>("propertyGrid");
//now i need refresh or reload the panel grid.


                    X.GetCmp<Window>("AddNewProperty").Close();
                    return this.Direct();
                    //return RedirectToAction("StyleProperties");
                }

So, resuming, I need refresh the PanelGrid datasource(or store) from the controller. Please can you help me?

4

2 回答 2

0

好的。我解决。我删除了 Store 中的数据源,并将代理阅读器放入 Controller。

.Proxy(
       Html.X().AjaxProxy()
       .Url(Url.Action("Read"))
       .Reader(Html.X().JsonReader().Root("data"))
      )

在控制器中:

public ActionResult Read()
        {
            var db = new TaosKnowledgeDataContext(DataUtils.GetConStringLocal());
            var properties = db.StylesPropertyDefs.OrderBy(o => o.PropertyId);
            return this.Store(properties);
        }

当插入新属性时:

var store = X.GetCmp<Store>("Store1");
store.Reload();

不管怎么说,多谢拉。

于 2013-06-07T14:54:23.610 回答
0

请尝试以下方法。

  1. 为商店设置一个 ID。

    .ID("Store1")
    
  2. 在控制器操作中执行以下操作。

    Store store = X.GetCmp<Store>("Store1");
    store.DataSource = db.StylesPropertyDefs.OrderBy(o => o.PropertyId);
    store.DataBind();
    
于 2013-06-07T05:53:12.240 回答