This is a migrated thread and some comments may be shown as answers.

RadWindow as edit dialog for RadGrid

2 Answers 76 Views
Window
This is a migrated thread and some comments may be shown as answers.
John Swenson
Top achievements
Rank 1
John Swenson asked on 04 Sep 2012, 10:43 PM
Hi,
I'm using the techniques described here in order to use RadWindow as insert/edit dialog for RadGrid.

Now, I have several pages with this code, so I'm concerned about having to repeat the same code for all pages; I'm wondering if I can put the JavaScript code into two separate files, one for the page with the RadGrid and one for the page showed with the RadWindows in order to optimize page load and simplify pages maintenance.

Any suggestion and/or sample code will be greatly appreciated.Thank you.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Sep 2012, 05:52 AM
Hi,

You can put the JavaScript code into two separate files. You can add the required functions in a js file and then refer the path as shown below.

ASPX:
<head runat="server">
    <script src="../Grid.js" type="text/javascript"></script>
</head>

Grid.js

JS:
function ShowEditForm(id, rowIndex) {
    var grid = $find("RadGrid1");
    var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
    grid.get_masterTableView().selectItem(rowControl, true);
    window.radopen("EditWindow.aspx?EmployeeID=" + id, "UserListDialog");
    return false;
}
function ShowInsertForm() {
    window.radopen("EditWindow.aspx", "UserListDialog");
    return false;
}
function refreshGrid(arg) {
    if (!arg) {
        $find("RadAjaxManager1").ajaxRequest("Rebind");
    }
    else {
        $find("RadAjaxManager1").ajaxRequest("RebindAndNavigate");
    }
}
function RowDblClick(sender, eventArgs) {
    window.radopen("EditWindow.aspx?EmployeeID=" + eventArgs.getDataKeyValue("EmployeeID"), "UserListDialog");
}

Hope this helps.

Regards,
Princy.
0
John Swenson
Top achievements
Rank 1
answered on 07 Sep 2012, 09:55 AM
Thank you for answering, Princy.

However, my concerns are about server side code, in particular the use of RegisterStartupScript: does it works if I put the JS code in separate files? Can you give me some working example, please?

Thank you.
Tags
Window
Asked by
John Swenson
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
John Swenson
Top achievements
Rank 1
Share this question
or