Telerik Grid:选择问题

发布于 2024-11-05 17:33:23 字数 1480 浏览 0 评论 0原文

我有以下数据绑定。分配给我的“编辑”按钮和“选择”按钮的实际 URL 是:/Home/Selection/。我认为情况不应该如此。 为什么我的选择按钮的操作也分配给我的编辑按钮。它们都有用于 Controller/Action/Home/Selection

我的删除按钮具有称为删除的正确操作。 /Home/Delete/ 基于下面的绑定定义。

请参阅下面的数据绑定,数据绑定绑定名为“Selection”的操作和名为Home控制器。我认为它会调用 ~/Home/Selection/5? 当单击选择按钮时,我收到 404 not found 错误。任何帮助表示赞赏。

  1. 为什么我收到 404 错误。
  2. 为什么编辑和选择按钮分配了相同的操作?

public ActionResult Index()
        {            
            ProjectViewModel objProjectViewModel = new ProjectViewModel();
            objProjectViewModel.ProjectList = Repository.GetProjects();


            return View(objProjectViewModel);

        }



[HttpPost]
[GridAction]
  public ActionResult Selection(long id)
        {
            ProjectViewModel objProjectViewModel = new ProjectViewModel();
            objProjectViewModel.ProjectHierarchy = Repository.GetProjects(id);

            ViewBag["id"] = id;
            return View(objProjectViewModel);
        }

数据绑定

.DataBinding(dataBinding => dataBinding.Server().Select("Selection", "Home")
                                            .Insert("Insert", "Home")
                                            .Update("Update", "Home")
                                            .Delete("Delete", "Home")
                                            )

I have the following databinding. The actual URL assigned to my Edit button and Select button is : /Home/Selection/. I do not think that this should be the case.
Why does the action for my select button get assigned to my edit button also. They both have /Home/Selection for the Controller/Action

My Delete button has the correct action called delete. /Home/Delete/ based on the binding definition below.

See databind below, The databinding binds an action called "Selection" and controller called Home. I would think that it would call ~/Home/Selection/5? I get a 404 not found error when clicking the select button. Any help is appreciated.

  1. Why am I getting 404 error.
  2. why does the edit and select button have the same action assigned?
public ActionResult Index()
        {            
            ProjectViewModel objProjectViewModel = new ProjectViewModel();
            objProjectViewModel.ProjectList = Repository.GetProjects();


            return View(objProjectViewModel);

        }



[HttpPost]
[GridAction]
  public ActionResult Selection(long id)
        {
            ProjectViewModel objProjectViewModel = new ProjectViewModel();
            objProjectViewModel.ProjectHierarchy = Repository.GetProjects(id);

            ViewBag["id"] = id;
            return View(objProjectViewModel);
        }

DATABINDING

.DataBinding(dataBinding => dataBinding.Server().Select("Selection", "Home")
                                            .Insert("Insert", "Home")
                                            .Update("Update", "Home")
                                            .Delete("Delete", "Home")
                                            )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傻比既视感 2024-11-12 17:33:23

您在 Grid 上设置了 DataKey 吗?

Html.Telerik().Grid(...)
.DataKeys(dataKeys => dataKeys.Add(o => o.Id))

Do you have a DataKey set on the Grid?

Html.Telerik().Grid(...)
.DataKeys(dataKeys => dataKeys.Add(o => o.Id))
心凉 2024-11-12 17:33:23

以下是 Telerik 支持人员的说法:

这是设计使然。网格使用查询字符串参数来确定它是否处于编辑模式。您可以在我们的在线演示中看到这一点。
http://demos .telerik.com/aspnet-mvc/Grid/EditingServerSide/1?mode=InLine&type=Text&Grid-mode=edit

Telerik 团队

Here is what telerik support said:

This is by design. The grid uses a query string argument to determine that it is in edit mode. You can see this in our online demo.
http://demos.telerik.com/aspnet-mvc/Grid/EditingServerSide/1?mode=InLine&type=Text&Grid-mode=edit

the Telerik team

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文