When data is loaded in kendo mvc listview, how to make first record is automatically selected and display the result in SkeletonContainer? when there is no item to select it shouldn't throw any kind of error
is there any way to keep multiselect dropdown in search and pass multiple values from same dropdown when user clicks search
@{
ViewBag.Title = "Search Jobs";
}
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@model IDOHJobBank.Data.Models.UserSearchViewModel
<div>
<form style="padding-bottom: 10px; padding-left:10px; padding-right:10px;">
<div class="row">
<div class="col-md-1">
</div>
<div class="col-md-2">
@Html.DropDownListFor(model => model.JobTitle, new SelectList(
Model.ddlTitles, "Id", "Name", 0), "Select Title", new { @class = "form-control" })
</div>
<div class="col-md-2">
@Html.DropDownListFor(model => model.countyName, new SelectList(
Model.ddlCounties, "Id", "Name", 0), "Select County", new { @class = "form-control" })
</div>
<div class="col-md-2">
@Html.DropDownListFor(model => model.jobType, new SelectList(
Model.ddlJobTypes, "Id", "Name", 0), "Select JobType", new { @class = "form-control" })
</div>
<div class="col-md-2">
@Html.DropDownListFor(model => model.divName, new SelectList(
Model.ddlDivisions, "Id", "Name", 0), "Select Division", new { @class = "form-control" })
</div>
<div class="col-md-2">
<input type="button" name="Search" value="Search" style="text-align:center;" class="btn btn-info" id="btnSubmit">
<input type="button" name="Clear" value="Clear" style="text-align:center;" class="btn btn-info" id="btnClear">
</div>
@*<div class="col-md-1">
</div>*@
</div>
</form>
</div>
<script type="text/x-kendo-tmpl" id="leftTemplate">
<div class="product">
<P style="font-size:medium; font-weight: bold">#:Title#</P>
<p style="margin: 0px 0px 5px;"> Posted Date : #: kendo.toString(PostDate, "MM/dd/yyyy")# </p>
<p style="margin: 0px 0px 5px;"> Positions Available : #= Vacancies # </p>
<p style="margin: 0px 0px 5px;"> County : #= County # </p>
<hr>
<p>#= JobDesc #</p>
</div>
</script>
<script>
function onChange(e) {
var selected = e.sender.select();
//console.log(selected)
var dataItem = e.sender.dataItem(selected[0])
$.ajax({
type: "GET",
url:"@Url.Action("GetCard","User")",
data: { id: dataItem.ID },
success: function (viewHTML) {
$("#skeleton").hide();
$(".selected-item").html(viewHTML);
},
error: function (errorData) { console.log(errorData) }
});
}
function onDataBound(e) {
//var listView = $('#jobsListView').data('kendoListView');
////listView.select(listView.element.children().first());
//listView.select(".k-first");
//var listView = e.sender;
//alert(listView);
//var firstItem = listView.element.children().first();
//listView.select(firstItem);
//// get a reference to the ListView widget
//var listView = $("#jobsListView").data("kendoListView");
//// selects first ListView item
//console.log(listView.content.children().first());
//listView.select(listView.content.children().first());
}
function searchCriteria() {
return {
JobTitle: $("#JobTitle").val(),
countyName: $("#countyName").val(),
jobType: $("#jobType").val(),
divName: $("#divName").val()
};
}
$("#btnSubmit").click(function () {
$("#jobsListView").data("kendoListView").dataSource.read();
});
$("#btnClear").click(function () {
$("#JobTitle").val('');
$("#countyName").val('');
$("#jobType").val('');
$("#divName").val('');
$("#jobsListView").data("kendoListView").dataSource.read();
});
</script>
<div class="parent">
<div class="demo-section narrow">
@(Html.Kendo().ListView<IDOHJobBank.Data.Models.UserJobDetails>()
.Name("jobsListView")
.TagName("div")
.ClientTemplateId("leftTemplate")
.DataSource(dataSource => dataSource
.PageSize(10)
.Model(m =>
{
m.Id(f => f.ID);
}
)
.Read(read => read.Action("Jobs_Read", "User").Data("searchCriteria"))
)
.Scrollable()
.Pageable()
.Selectable(s => s.Mode(ListViewSelectionMode.Single))
.Events(e => { e.Change("onChange"); e.DataBound("onDataBound"); })
)
</div>
<div class="selected-item" style="display:block;">
@(Html.Kendo().SkeletonContainer()
.Name("skeleton")
.Animation(SkeletonContainerAnimation.Pulse)
.Template(
"<div class='k-card'>" +
"<div class='k-card-header'>" +
"<div>" +
"<span data-shape-circle class='k-card-image avatar'></span>" +
"</div>" +
"<div class='user-info' style='width: 100%;'>" +
"<span data-shape-text class='k-card-title'></span>" +
"<span data-shape-text class='k-card-subtitle' style='width: 35%;'></span>" +
"</div>" +
"</div>" +
"<span data-shape-rectangle style='width: 800px; height: 480px; '></span>" +
"<div class='k-card-body'>" +
"<span data-shape-text></span>" +
"</div>" +
"</div>"+
"</div>")
)
</div>
</div>
<style>
.container-fluid {
display: block;
}
.parent {
display: flex;
}
.parent > div {
display: inline-block;
}
.narrow {
width: 35%;
}
.narrow > .k-pager {
border-color: transparent;
background-color: rgb(255,255,255);
}
.k-listview {
border-color: transparent;
}
.selected-item {
padding: 10px 5px;
}
.card {
width: 60%;
height: 480px;
}
#jobsListView {
padding: 10px 5px;
margin-bottom: -1px;
min-height: 510px;
height: auto !important;
/* Avoid cutout if font or line is bigger */
font: inherit;
}
.product {
float: left;
position: relative;
width: 95%;
height: auto !important;
margin: 0 5px;
margin-bottom: 10px;
padding: 5px;
border: 0.5px solid grey;
border-radius: 5px;
}
.product img {
width: 150px;
height: 150px;
}
.product h3 {
margin: 0;
padding: 3px 5px 0 0;
max-width: 96px;
overflow: hidden;
line-height: 1.1em;
font-size: .9em;
font-weight: normal;
text-transform: uppercase;
color: black;
}
.main-image {
width: 180px;
height: 180px;
}
.k-listview:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.scrollable {
overflow-y: auto;
max-height: 400px;
}
.k-card {
border-radius: 6px;
border-width: 1px;
border-style: solid;
box-sizing: border-box;
outline: 0;
font-family: inherit;
font-size: 14px;
line-height: 1.4285714286;
display: flex;
flex-direction: column;
position: fixed;
overflow: hidden;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.k-textbox, .k-textbox > input {
font-size: 100%;
font-family: inherit;
border-style: solid;
border-width: 1px;
-webkit-appearance: none
}
</style>
using IDOHJobBank.Data.Models; using IDOHJobBank.Data.Services; using Kendo.Mvc.Extensions; using Kendo.Mvc.UI; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace IDOHJobBank.External.UI.Controllers { public class UserController : Controller { private JobBankExternalService eService; public UserController() { eService = new JobBankExternalService(); } // GET: User public ActionResult Jobs() { var vm = eService.GetUserDropdownValues(); return View(vm); } public ActionResult Jobs_Read([DataSourceRequest] DataSourceRequest request, string JobTitle, string countyName, string jobType, string divName) { var usrSearch = new UserSearchViewModel { JobTitle = JobTitle, countyName = countyName, jobType = jobType, divName = divName }; var jobList = eService.GetUserJobDetails(usrSearch); //var result = GetAll(); return Json(jobList.ToDataSourceResult(request)); } public ActionResult GetCard(int id) { var model = eService.GetUserJobDetailsByID(id); return PartialView("_Card", model); } } }
I am trying to find a way to populate a Listview without the need to create a Read action. currently, in my Controller class, I have an action method that gets called with a query string.
Controller.cs
public IActionResult Report(string blocknumber)
{
var model = new List<Report>();
model = _maExtensionService.GetReport(blocknumber).Result.ToList();
ViewBag.BlockList = model;
return View();
}
My cshtml
Report.cshtml
@(Html.Kendo().ListView<Report>(ViewBag.BlockList as IEnumerable<Report>)
.Name("Reportgrid")
.TagName("div")
.Pageable())
I have tried to use ViewBag in different ways and also Viewdata to bind and or hold data to be used on the page. When the page loads I am not seeing data populate the Listview. Is there another way I should be doing this? Thank you for your time
HI,
I am trying to implement same as in the below link. Left side I will have some kind Post. When user clicks on post, a detail description of the post and link to post. How can i achieve that using Kendo UI.
https://www.indeed.com/?vjk=ecee10295b7129db&advn=2889100715288898
Thanks
Hi There,
Nested ListView requirement.
Is there any way we can implement nested listview for given design?
Thank You,
BDP
I have an app thats working with SignalR grids, but now we want to add bearer auth.
The token handling stuff has to happen before my SignalR promise is set, but the problem is the Kendo components required the SignalR promise to bind.
How can I set a SignalR promise that the Kendo components can use which will not resolve until my own token handling functions are complete?
Here is a sample of what we're doing:
getTokenPopup({ scopes: ["api://918c95d7-8c39-4486-9e15-83d061a30fa6/access_as_user"] }) .then(response => { $.ajaxSetup({ beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', 'Bearer ' + response.accessToken); } }); myApp.hub = $.connection.searchHub; myApp.hubStart = $.connection.hub.start({ waitForPageLoad: false, transport: "longPolling" }); }) .catch(error => { console.error(error); });
https://docs.telerik.com/aspnet-mvc/html-helpers/data-management/listview/binding/ajax-binding
@(Html.Kendo().ListView<ListViewCore.Models.OrderViewModel>() .Name("ListView") .TagName("div") .ClientTemplateId("template") .DataSource(dataSource => dataSource .Ajax() .PageSize(6) .Read(read => read.Action("Orders_Read", "ListView").Data("additionalData")) ) .Pageable() ) <script> function additionalData() { return { firstName: "John", lastName: "Doe" }; } </script>
the .Ajax() instantly doenst work. EVERY sample fails !!!
Anyone have a listview<T> that actually works? the demos and samples all fail.
i am getting the error when i use @html.kendo()
it showing are you missing any directives
>please suggest any solution
Hi , Creating Bot like application using kendo list view.
If the Current logged in user Name is matched with exiting comment , then create div and align left else align div right. Not able to do in a template.
Please help:
Thanks
Karthey