or
I have a question about duplicate static window content script initialization.
Let's see an example:
I have a KendowUI Window with static content:
@Html.Kendo().Window().Name("Window").Content(@<div>
<script type="text/javascript">
$(document).ready(function () {
alert('It\'s me!');
});
</script>
</div>).Visible(false).Modal(true).Title("Test").Draggable(false)
So when I am opening page with provided code I see two alerts.
Please help me to find different solution except provided below:
<script type="text/javascript">
$(document).ready(function () {
alert('It\'s me!');
});
</script>
@Html.Kendo().Window().Name("Window").Content(@<div>
</div>).Visible(false).Modal(true).Title("Test").Draggable(false)
This is very important for me for initializing KendoUI controls inside of static window content.
<fieldset class="form-list"> <ol> <li> <label>Project *</label> @(Html.Kendo().DropDownList() .Name("1Project") .DataTextField("DisplayName") .DataValueField("ProjectID") .DataSource(source => { source.Read(read => { read.Action("ProjectList", "ReturnMail"); }); }) ) </li> <li> <label>Name Address 1</label> <input type="text" id="1NameAddress1" class="k-textbox" /> </li> <li> <label>Name Address 1</label> <input type="text" id="1NameAddress2" class="k-textbox" /> </li> <li> <label>Name Address 1</label> <input type="text" id="1NameAddress3" class="k-textbox" /> </li> <li> <label>Name Address 1</label> <input type="text" id="1NameAddress4" class="k-textbox" /> </li> <li> <label>Name Address 1</label> <input type="text" id="1NameAddress5" class="k-textbox" /> </li> <li> <label>City</label> <input type="text" id="1City" class="k-textbox" /> </li> <li> <label>State</label> <input type="text" id="1State" class="k-textbox" maxlength="2" /> </li> <li> <label> </label> <button id="SearchAddressButton" class="k-button primary">Search</button> </li> </ol> </fieldset>
Controller Code:public JsonResult ProjectList(string userName = "") { if (userName == "") userName = Request.ServerVariables["AUTH_USER"]; List<ProjectModel> proj = ProjectModel.AllProjects(); return Json(proj); }
<div id="userGrid" data-role="grid" data-columns='[{ "field": "Name", "title": "Users"}]' data-filterable='true' data-navigatable="false" data-pageable='true' data-selectable="row" data-sortable='{"mode": "single", "allowUnsort": true}' data-bind="source: userDataSource"></div>
public ActionResult ListUsers([DataSourceRequest] DataSourceRequest request) { return Json(GetUsers().ToDataSourceResult(request)); } When using attribute-driven, the grid works fine listing the records and the paging also works. But not the filter and sorting. Debugging the controller, I found out that the "request" parameter only has the Page and PageSize values, while the Filter and Sort properties are null. Looking at the POST request sent by each version of the grid, I found some differences. This is the request sent by the Grid created with the MVC helper: sort:
page:1
pageSize:10
group:
filter:Name~contains~'aaa' And this is the request sent by the attribute-driven: take:30
skip:0
page:1
pageSize:30
sort[0][field]:Name
sort[0][dir]:asc
filter[filters][0][field]:Name
filter[filters][0][operator]:contains
filter[filters][0][value]:25
filter[logic]:and
read: function (options) { $.ajax({ url: '/home/ListUsers', type: 'POST', data: options.data, success: function (data, textStatus, jqXHR) { options.success(data); }, error: function (jqXHR, textStatus, errorThrown) { alert(errorThrown); } }); }
@(Html.Kendo().DatePicker().Name("Test").Value(DateTime.Now))<input name="Test" id="Test" value="@DateTime.Now" /><script type="text/javascript"> $(document).ready(function () { $('#DebutJ').kendoDatePicker(); });</script>