What i wanted is click a button and open a bootstrap modal-dialog which is dynamic load from server and append to <body> and show.
in currentPage, a button onclick even code is
var dialog = $('<div class="modal fade" id="editDialog" tabindex="-1" role="dialog" aria-labelledby="editDialogTitleLabel"></div>');
dialog.load("/Role/Authorize", rowData, function (response, status, xhr) { });
$("body").append(dialog);
dialog.modal({
backdrop: 'static'
});
the url "/Role/Authorize" return a PartialView with a viewmodel, the PartialView code is
@model WDPMis.Web.ViewModels.AuthorizeRoleViewModel
<div class="modal-dialog" role="document" modal-lg aria-hidden="true">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="editDialogTitleLabel">Role Authorize</h4>
</div>
<div class="modal-body">
<h5>Function List</h5>
<div id="ModuleTreeGridContainer"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save</button>
</div>
</div>
</div>
<script src="~/Scripts/SystemManager/RoleAuthorize.js"></script>
and in RoleAuthorize.js has init the treeview.
$(document).ready(function () {
initModuleTreeGrid();
});
function initModuleTreeGrid() {
var dm = ej.DataManager({
url: "/Module/DataSource",
adaptor: "UrlAdaptor"
});
$('#ModuleTreeGridContainer').ejTreeGrid({
dataSource: dm,
isResponsive: true,
selectedRowIndex: 0,
sizeSettings: {
height: '200px',
width: '400px'
},
allowSorting: true,
sortSettings: { sortedColumns: [{ field: "CodeOrdinal" }] },
treeColumnIndex: 0,
idMapping: "ID",
parentIdMapping: "ParentID",
selectionSettings: {
selectionType: ej.TreeGrid.SelectionType.Checkbox,
selectionMode: ej.TreeGrid.SelectionMode.Row,
enableSelectAll: false,
enableHierarchySelection: true
},
columns: [
{ field: "Name", headerText: "Name", headerTextAlign: "center", type: "string" },
{ field: "Code", headerText: "Code", headerTextAlign: "center", type: "string" },
{ field: "CodeOrdinal", headerText: "CodeOrdinal", headerTextAlign: "center", type: "string" },
{ field: "Description", headerText: "Description", headerTextAlign: "center", type: "string" },
{ field: "ID", isPrimaryKey: true, visible: false },
{ field: "ParentID", visible: false }
],
});
var treeObject = $("#ModuleTreeGridContainer").ejTreeGrid("instance");
treeObject.updateCheckboxColumn('Name');
}
the problem is treegrid can only be shown at first time of the button-click.
rare can be shown at second time but the positon is error,
from browser tools i can see the RoleAuthorize.js not called from the second time.
i changed the code to mvc method like @(Html.EJ().TreeGrid("ModuleTreeGridContainer") ........ but it doesn't work too.
what's wrong with the above code?
thanks a lot!