Kendo DropDownList is marking all items as Selected - model-view-controller

I have gotten a partial view to work in which I am binding a kendo dropdownlist to a remote datasource. I reuse this partial 5 times in my view. I pass the value to the Controller method in order to dynamically bind the data for each instance of the control (just like it was done in ascx file).
My problem is that for 2 of these dropdownlists, the entire list comes back as selected. I am not binding the data yet with a model view data that comes from an instance of the model, just a blank form at this point.
Here is one of my rendered HTML kendo dropdownlists that has the issue:
<ul tabindex="-1" class="k-list k-reset" id="Title_listbox" role="listbox" aria-hidden="true" aria-live="off" data-role="staticlist" unselectable="on">
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="0"></li>
<li tabindex="-1" class="k-item k-state-selected k-state-hover" role="option" aria-selected="true" unselectable="on" data-offset-index="1">Attorney</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="2">CEO</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="3">CFI</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="4">CFO</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="5">Chairman</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="6">Chairperson</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="7">Consultant</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="8">COO</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="9">Coordinator</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="10">CPA</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="11">Director</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="12">EVP</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="13">Executive</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="14">Judge</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="15">Manager</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="16">Owner</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="17">Partner</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="18">President</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="19">Principal</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="20">Superintendant</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="21">Supervisor</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="22">Treasurer</li>
<li tabindex="-1" class="k-item k-state-focused" id="970fd67b-52fe-4519-b2f8-36cae7068b32" role="option" aria-selected="false" unselectable="on" data-offset-index="23">Vice President</li>
Here is my partial view code:
<script type="text/javascript">
function LookupInfo(lookupID) { return { LookupTypeID: lookupID }; }
function LookupInfo_DataBound() { this.value("#Model.SelectedLookupID"); }
</script>
<div class="editor-field">
#(Html.Kendo().DropDownList()
.Name(#Model.LookupName)
.HtmlAttributes(new { #id = Model.LookupName.ToString(), #class = "myclass" })
.DataTextField("Name")
.DataValueField("Value")
.SelectedIndex(#Model.SelectedLookupID)
.Events(events => events.DataBound("LookupInfo_DataBound"))
.DataSource(dataSource => dataSource
.Read(read => read.Action("GetLookup", "Contact").Data("LookupInfo("+#Model.LookupTypeID+")")
)
)
)
</div>
I tried supplying .SelectedIndex(0) but that did not work!
The event call is doing at least one good this, in that the rendered result now doesn't show the last item in the list as the selected item.
I do not what a solution for using jQuery to "fix" the problem.
Didn't post my controller code because it is irrelevant here. Data is binding as expected in all 5 cases, except that with two of the lists, all the items are selected.

Related

Bootstrap nav-tabs not working when published

I'm building a Intranet Blazor server app. I've added Bootstrap nav-tabs which work as expected launching the Blazor project in Visual Studio. However, the tabs do not work when published to the IIS server. All other Bootstrap classes appear to be working ok.
<nav>
<div class="nav nav-tabs" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-1" target="_self" role="tab" aria-controls="nav-1" aria-selected="true">General Details</a>
<a class="nav-item nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-2" target="_self" role="tab" aria-controls="nav-2" aria-selected="false">Stationery</a>
<a class="nav-item nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-3" target="_self" role="tab" aria-controls="nav-3" aria-selected="false">Final Details</a>
</div>
</nav>
<div class="tab-content" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-1" role="tabpanel" aria-labelledby="nav-home-tab">Some text</div>
<div class="tab-pane fade" id="nav-2" role="tabpanel" aria-labelledby="nav-2-tab">...</div>
<div class="tab-pane fade" id="nav-3" role="tabpanel" aria-labelledby="nav-3-tab">...</div>
</div>
#*Stationery shows ... run from visual studio, but goes to the homepage displaying /#nav-2 in the address bar*#

jqGrid inside a bootstrap tab won't show

I'm using jqGrid JS 5.3.0 with styleUI set to Bootstrap. The grid displays fine without bootstrap tabs, but with this html (below copied from getbootstrap.com with mygrid "embedded") the content area is blank with no grid.
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade" id="home" role="tabpanel" aria-labelledby="home-tab">
<div><table id="mygrid"></table><div id="mygrid_pager"></div></div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>
How can I make it work inside a "tab-pane"? TIA.
(can't include javascript code of creating "mygrid" right now)
You need to change your code from
<div class="tab-pane fade" id="home" role="tabpanel" aria-labelledby="home-tab">
<div><table id="mygrid"></table>
to
<div class="tab-pane fade in" id="home" role="tabpanel" aria-labelledby="home-tab"> <table id="mygrid"></table></div>
adding the in class to your #home will show it on load (judging from <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a> you want it to show on load)
and moving <table id="mygrid"></table> into div#home will show your grid inside the tab.

how do I add loader on tab click

could anyone help me adding this for navigating threw tabs. I want it to have some kind of loader just for the look.
http://jsfiddle.net/3KAnM/33/ loader
tabs example:
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><i class="fa fa-globe"></i>  <span>NORTH AMERICA</span></li>
<li role="presentation"><i class="fa fa-globe"></i>  <span>EUROPE</span></li>
<li role="presentation" class="unverifiedna"><i class="fa fa-globe"></i>  <span>NA UNVERIFIED</span></li>
<li role="presentation" class="unverifiedeuw"><i class="fa fa-globe"></i>  <span>EUW UNVERIFIED</span></li>
<li role="presentation" class="pbe"><i class="fa fa-globe"></i>  <span>PBE</span></li>

Xpath CasperJS, take last element

i have a problem with Xpath.
I have that :
<ul unselectable="on" class="k-list k-reset" tabindex="-1" role="listbox" aria-hidden="true" id="1 (fix but random)" aria-live="off" style="overflow: auto;">
<li tabindex="-1" role="option" unselectable="on" class="k-item"></li>
<li tabindex="-1" role="option" unselectable="on" class="k-item">standard 2014</li>
<li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" id="1 (fix but random)__PackageId_option_selected" aria-selected="true">standard couple 2014</li><li tabindex="-1" role="option" unselectable="on" class="k-item">Gratuit</li>
</ul>
<ul unselectable="on" class="k-list k-reset" tabindex="-1" role="listbox" aria-hidden="true" id="2 (fix but random)" aria-live="off" style="overflow: auto;">
<li tabindex="-1" role="option" unselectable="on" class="k-item"></li>
<li tabindex="-1" role="option" unselectable="on" class="k-item">standard 2014</li>
<li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" id="1 (fix but random)__PackageId_option_selected" aria-selected="true">standard couple 2014</li><li tabindex="-1" role="option" unselectable="on" class="k-item">Gratuit</li>
</ul>
<ul unselectable="on" class="k-list k-reset" tabindex="-1" role="listbox" aria-hidden="true" id="RANDOM" aria-live="off" style="overflow: auto;">
<li tabindex="-1" role="option" unselectable="on" class="k-item"></li>
<li tabindex="-1" role="option" unselectable="on" class="k-item">standard 2014</li>
<li tabindex="-1" role="option" unselectable="on" class="k-item k-state-selected k-state-focused" id="1 RANDOM__PackageId_option_selected" aria-selected="true">standard couple 2014</li><li tabindex="-1" role="option" unselectable="on" class="k-item">Gratuit</li>
</ul>
My question is simple : how can i click with casper on last < li > with standard 2014 ?
I try that :
var x = require('casper').selectXPath;
this.click(x('//*ul[#class="k-list k-reset"]/li[text() = "standard 2014"]'))
But casperjs don't find.
Thank's for your help !
Try surrounding your xpath in parentheses and adding [last()] to the end. Like (xpath)[last()]
You should also remove the asterisk from //*ul
It should look like this:
this.click(x('(//ul[#class="k-list k-reset"]/li[text() = "standard 2014"])[last()]'))
You should try to check whether your X-path is valid or not in console of browser. like
$x('//a[contains(text(),"Cancel")]')

Navbar split button dropdown with Bootstrap 3

I'd like to make a split button dropdown with Bootstrap 3. I didn't find any working snippet.
My navbar looks like:
<header class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
Example
</li>
<li>
Example
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div><!--/.navbar-collapse -->
</div>
</header>
You can place it inside the nav li and add navbar-btn to the btn-group..
<li>
<div class="btn-group navbar-btn">
<button class="btn btn-danger">Action</button>
<button data-toggle="dropdown" class="btn btn-danger dropdown-toggle"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</div>
</li>
Demo: http://bootply.com/100070

Resources