Telerik MVC 网格的定位编辑表单弹出窗口

发布于 2024-10-05 10:02:57 字数 42 浏览 7 评论 0原文

谁能告诉我是否有办法将 mvc 网格的编辑表单弹出窗口定位到屏幕中心?

Can anybody tell me if there is a way to position the edit-form Popup for an mvc grid to align to the center of the screen?

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

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

发布评论

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

评论(5

夏有森光若流苏 2024-10-12 10:02:57

感谢大家的有效回答。我知道我们可以定位自定义弹出窗口,但不能定位内置编辑模式窗口。

但是我操纵了位置
在客户端使用 jquery on_edit
Telerik 网格的 API。

var popup = $("#" + e.currentTarget.id + "PopUp");

 popup.css({ "left": ($(window).width()/2 - $(popup).width()/2) + "px", "top": ($(window).height()/2 - $(popup).height()/2) + "px" }); 

e.currentTarget.id 给出网格名称。

thanks guys for the valid answers. I know we can position a custom popup window but not for built in edit mode windows.

However I manipulated the position
with jquery on the client side on_edit
API of telerik grid.

var popup = $("#" + e.currentTarget.id + "PopUp");

 popup.css({ "left": ($(window).width()/2 - $(popup).width()/2) + "px", "top": ($(window).height()/2 - $(popup).height()/2) + "px" }); 

e.currentTarget.id gives the gridname.

梦巷 2024-10-12 10:02:57

我的朋友发现了最简单的方法,使用 Telerik 网格的未公开的内置函数之一,

        var popup = $("#" + e.currentTarget.id + "PopUp");
        //get the data window contained by the popup
        var popupDataWin = popup.data("tWindow");

        //change popup title by calling the title 
        popupDataWin.title("Custom Title");            
        //center the window by calling the method center
        popupDataWin.center();

将这段代码放入网格的客户端 on_edit api 中,您将看到神奇的效果

My friend found out the easiest way of doing by using one of the unexposed inbuilt function of telerik grid

        var popup = $("#" + e.currentTarget.id + "PopUp");
        //get the data window contained by the popup
        var popupDataWin = popup.data("tWindow");

        //change popup title by calling the title 
        popupDataWin.title("Custom Title");            
        //center the window by calling the method center
        popupDataWin.center();

put this piece of code in client side on_edit api of the grid and you will see the magic

七堇年 2024-10-12 10:02:57

不确定这是否可以通过配置选项自动完成 - 现在在现场演示中,弹出窗口会在网格中居中。我的大胆猜测是,你可以使用 javascript 将其放置在屏幕中央......

Not sure whether this can be done automatically with configuration option - now on the live demos the popup gets centered in the grid. My wild guess is that you can position it in the center of the screen with javascript...

ら栖息 2024-10-12 10:02:57

我在使用单独定义的 Telerik Mvc 窗口的自定义弹出窗口之前已经完成了此操作。我的示例代码如下所示:

   <%= Html.Telerik().Window()
    .Name("CompanyWindow")
    .Title("Company Details")
    .Buttons(b => b.Maximize().Close())
    .Visible(false)
    .Modal(true)
    .Width(600)
    .Height(600)
    .Draggable(true) 
    .Resizable()
%>

<% Html.Telerik().Grid<Vigilaris.Booking.Services.CompanySummaryDTO>()
   .Name("CompaniesGrid")
   .ToolBar(tb => tb.Template(() => { %>
       <a href ="#" onclick="createCompany()" >Insert</a>
       <% }))
   .Columns(col =>
       {
           col.Bound(c => c.Id).Width(20);
           col.Bound(c => c.CompanyName).Width(120);
           col.Bound(c => c.ResponsiblePersonFullName).Width(160);
           col.Bound(c => c.ResponsiblePersonUserName).Width(160);
           col.Bound(c => c.ResponsiblePersonEmail).Width(160);
           col.Command(cmd =>
               {
                   cmd.Edit().ButtonType(GridButtonType.Image);
               }).Title("Edit");
       })
   .DataKeys(keys => keys.Add(c => c.Id))
   .DataBinding(binding => binding.Ajax()
       .Select("_IndexAjax", "Company")
       .Insert("_InsertAjax", "Company")
       .Update("_UpdateAjax", "Company")
   )
   .Sortable()
   .Render();
%>

<script type="text/javascript">
    function createCompany() {
        var url = '<%= Url.Action("New", "Company") %>'
        $.post(url, function (data) {
            var window = $('#CompanyWindow').data('tWindow');
            window.content(data);
            window.center().open();
        });
    }
</script> 

您会注意到在 createCompany 函数中我调用了 window.center().open()。这明确地将弹出窗口居中。

然而,我不认为这正是您想要做的,但它可能会给您一些正确方向的指示。我希望它有帮助。

I have done this before using a custom popup using a separately defined Telerik Mvc Window. My sample code looked like this:

   <%= Html.Telerik().Window()
    .Name("CompanyWindow")
    .Title("Company Details")
    .Buttons(b => b.Maximize().Close())
    .Visible(false)
    .Modal(true)
    .Width(600)
    .Height(600)
    .Draggable(true) 
    .Resizable()
%>

<% Html.Telerik().Grid<Vigilaris.Booking.Services.CompanySummaryDTO>()
   .Name("CompaniesGrid")
   .ToolBar(tb => tb.Template(() => { %>
       <a href ="#" onclick="createCompany()" >Insert</a>
       <% }))
   .Columns(col =>
       {
           col.Bound(c => c.Id).Width(20);
           col.Bound(c => c.CompanyName).Width(120);
           col.Bound(c => c.ResponsiblePersonFullName).Width(160);
           col.Bound(c => c.ResponsiblePersonUserName).Width(160);
           col.Bound(c => c.ResponsiblePersonEmail).Width(160);
           col.Command(cmd =>
               {
                   cmd.Edit().ButtonType(GridButtonType.Image);
               }).Title("Edit");
       })
   .DataKeys(keys => keys.Add(c => c.Id))
   .DataBinding(binding => binding.Ajax()
       .Select("_IndexAjax", "Company")
       .Insert("_InsertAjax", "Company")
       .Update("_UpdateAjax", "Company")
   )
   .Sortable()
   .Render();
%>

<script type="text/javascript">
    function createCompany() {
        var url = '<%= Url.Action("New", "Company") %>'
        $.post(url, function (data) {
            var window = $('#CompanyWindow').data('tWindow');
            window.content(data);
            window.center().open();
        });
    }
</script> 

You will notice in the createCompany function that I call window.center().open(). This explicitly centres the popup.

However, I don't think this is exactly what you want to do, but it may give you some pointers in the right direction. I hope it helps.

无边思念无边月 2024-10-12 10:02:57
@(Html.Telerik().Grid()
.Name("FormFildGrid")
.ClientEvents(events => events.OnEdit("Grid_onEdit"))

function Grid_onEdit(e) {
    var popup = $("#" + e.currentTarget.id + "PopUp");
    var popupDataWin = popup.data("tWindow");
    var l = ($(window).width() / 2 - $(popup).width() / 2);
    popup.css({ "left": l + "px", "margin-left": "0", "width": $(popup).width() });
}
@(Html.Telerik().Grid()
.Name("FormFildGrid")
.ClientEvents(events => events.OnEdit("Grid_onEdit"))

)

function Grid_onEdit(e) {
    var popup = $("#" + e.currentTarget.id + "PopUp");
    var popupDataWin = popup.data("tWindow");
    var l = ($(window).width() / 2 - $(popup).width() / 2);
    popup.css({ "left": l + "px", "margin-left": "0", "width": $(popup).width() });
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文