w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to show inner content in list item outside of that list item without being covered up by descending list items
You must set the z-index of the clicked 'li' higher and in return the former clicked 'li' back. Here is the example: fiddle And here the script: var oldli; $('li').click( function(){ $(oldli).toggleClass('displayNone displayBlock'); $(oldli).css("z-index","1"); $(this).toggleClass('displayBlock displayNone'); $(this).css("z-index","5"); oldli=$(this); } );

Categories : Javascript

Show SQLite data by clicking list item in a list populated by the Database
You need to change focusable mode of your TextView to false update TextView in XML android:focusable="false" lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long id) { data.moveToPosition(position); Toast.makeText(getApplicationContext(), c.getString(c.getColumnIndex("notes")), Toast.LENGTH_LONG).show(); speakOut(c.getString(c.getColumnIndex(BaseColumns._ID))); } });

Categories : Android

Python list manipulation: Add an item to a string element to make it a 2 item list
Modify a[0]: >>> a = ['spam', 'eggs', 100, 1234] >>> a[0] = [a[0], 'Devon'] >>> a [['spam', 'Devon'], 'eggs', 100, 1234] For your updated question: >>> items = ['devon', 'baloney'] >>> a = ['spam', 'eggs', 100, 1234] >>> a[0] = [a[0]] + items >>> a [['spam', 'devon', 'baloney'], 'eggs', 100, 1234] If you're not sure about the position of 'spam' then use a list comprehension: >>> a = ['spam', 'eggs', 100, 1234] >>> [item if item != 'spam' else [item, 'devon'] for item in a] [['spam', 'devon'], 'eggs', 100, 1234]

Categories : Python

WPF How to bind list to itemscontrol with each item being paired to a customcontrol and bound to the ith item in list
The DataContext for each UI item in the ItemsControl will automatically be assigned to the corresponding Data Item in the source Collection. Therefore this is valid and will work: <ItemsControl x:Name ="Signalviewer_Control" ItemsSource="{Binding Source = {StaticResource signal_data}, Path = list_of_signals}"> <ItemsControl.ItemTemplate> <DataTemplate> <wpfExp:SignalViewer Signal="{Binding}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>

Categories : Wpf

Appending an item to a python list in the declaration statement list = [].append(val) is a NoneType
The .append() function alters the list in place and thus always returns None. This is normal and expected behaviour. You do not need to have a return value as the list itself has already been updated. Use the dict.setdefault() method to set a default empty list object: >>> hash = {} >>> hash.setdefault('a', []).append('A') >>> hash {'a': ['A']} You may also be interested in the collections.defaultdict class: >>> from collections import defaultdict >>> hash = defaultdict(list) >>> hash['a'].append('A') >>> hash defaultdict(<type 'list'>, {'a': ['A']}) If you want to return a new list with the extra item added, use concatenation: lst = lst + ['val']

Categories : Python

Counting visible list items and then applying class to nth item of that list in jQuery?
Use $.each to iterate over the elements and then apply the logic. var $elems = $('.row-fluid ul.thumbnails li:visible'); $elems.each(function() { var $this = $(this); if($this.hasClass('span3')) { $this.filter(':nth-child(4n + 5)').addClass('span-left'); } else if($this.hasClass('span4')) { $this.filter(':nth-child(3n + 4)').addClass('span-left'); } else if($this.hasClass('span6')) { $this.filter(':nth-child(2n + 3)').addClass('span-left'); } });

Categories : Jquery

Python: Split a list into nested list at points where item matches criteria
Something like this: li = [1,2,3,4000,5,6,7,8,9000,10,11,12,1300] r = [[]] # start with a list containing an empty sub-list for i in li: if i >= 2000: # start a new sub-list when we see a big value r.append([i]) else: # append to the last sub-list of r r[-1].append(i)

Categories : Python

Generate unique list item id for all list items in site collection
There is no comparable feature to the documentID service for Items in general out of the box. You would have to build it using Custom code. You can create a custom ID which appends the list GUID and the OOTB item ID which is unique to every item in the site collection.

Categories : Sharepoint

How to iterate through an unordered list and then select the parent div of the list item
$('.question').filter(function () { return ! $(this).find('input:checked').length; }).addClass('highlight'); Here's the fiddle: http://jsfiddle.net/XTDre/

Categories : Javascript

Is it possible to paste a list to a select2 field and match each item in the list?
select2 provides a tokenizer option that lets you pre-process the input. here is a possible implementation for your particular usecase: tokenizer: function(input, selection, callback) { // no comma no need to tokenize if (input.indexOf(',')<0) return; var parts=input.split(","); for (var i=0;i<parts.length;i++) { var part=parts[i]; part=part.trim(); // todo: check for dupes (if part is already in [selection]) // check if the part is valid // todo: you will need a better way of doing this var valid=false; for (var j=0;j<unitIds.length;j++) { if (part===unitIds[j]) { valid=true; break; } } if (valid) callback({id:part,text:p

Categories : Jquery

How to I generate a CSV file from a python list with each list item in a seperate row
Use writerows as follow: myfile = open('/home/graham/Desktop/Experiment/listcsv.csv', 'wb') wr = csv.writer(myfile, quoting=csv.QUOTE_ALL) wr.writerows([path] for path in list_of_paths)

Categories : Python

Should adding a new item to a list<> update previous items in the list?
You're not adding several different items to the list, you're adding the same exact item several times and modifying it each time. Classes in C# are reference types; that means each variable doesn't hold the data for the object itself, it just hold onto a reference to where that object is. Assigning an object to another variable doesn't create a new object, it just copies the reference to that same object. The issue is that you should be creating a new object (i.e. using the new keyword) each time you go to add a new item to the list. From the looks of your code it would seem that StaticLists.GetStockMultibuyForBarcode(sBarcode) isn't returning a new item each time; it's just returning the same item, or at the very least one of the existing items. You should be creating a new item, co

Categories : C#

Refreshing the order of an ordered list, after appending a list item
Firstly, note that value is not a valid attribute of li, so your code is invalid. You should use a data attribute for any non-standard attributes you require, the you need to write a sorter function. Try this: $('#addThird').one('click', function() { $('ol').append('<li data-value="3">Third</li>'); sortItems(); }); var sortItems = function() { var $items = $('ol li'); $items.sort(function(a, b) { var keyA = $(a).data('value'); var keyB = $(b).data('value'); return (keyA > keyB) ? 1 : 0; }); $.each($items, function(index, row){ $('ol').append(row); }); } Updated fiddle This sorts by the data-value attribute of the element, but that can be amended as required.

Categories : Javascript

Retrieve values from list item when there are varying layouts in the list
Here's an easy way - paste this into each of the xml Views: android:onClick="someFunction" Then inside this someFunction do: public void someFunction(View v){ switch (v.getId()){ case R.id.lblSub: // This layout was clicked, do something about it break; case R.id.lblMain: // This layout was clicked, do something about it break; }

Categories : Android

Adding Sharepoint List Item to Windows form list
Completely untested, made fresh while drinking morning coffee. Good luck! var list = siteWeb.Lists.TryGetList(listName); if (list == null) { return; } var items = list.GetItems(query); var countOfItems = items.Count; if (countOfItems == 0) { return; } var listItemFieldObjects = items.Cast<SPListItem>().Select(item => item[1]); foreach (var item in listItemFieldObjects) { var listViewItem = new ListViewItem("Object's value"); listView.BeginUpdate(); listViewItem.SubItems.Add(item.ToString()); listView.Items.Add(listViewItem); listView.EndUpdate(); }

Categories : Sharepoint

delete items from a list that equals to index of other list item
checkboxtry this: <ul id="listone"> <li><input type="checkbox" class='chk' value="item1"/>item 1</li> <li><input type="checkbox" class='chk' value="item2"/>item 2</li> <li><input type="checkbox" class='chk' value="item3"/>item 3</li> </ul> <ul id="listtwo"> <li class="list_item1">item 1</li> <li class="list_item2">item 2</li> <li class="list_item3">item 3</li> </ul> <ul id="listThree"> <li class="list_item1">other item 1</li> <li class="list_item2">other item 2</li> <li class="list_item3">other item 3</li> </ul> $(".chk").click(function () { var isChecked = $(this).is(':checked'); if (!isChecked) {

Categories : Javascript

Infinite loop on list item in unordered list using jQuery
So your update was a good start... I adapted it to include 3 items (jquery selector) rather than 1 and added a fadeOut on the callback of fadeIn to achieve the cycle what you were looking for. After the callback reaches the end of the list, we start over. See below function fadeInSequence($three) { //default to the first three list items if ($three == null) $three = $('.sponsors>li:lt(3)'); //fade in the 3 found $three.fadeIn(2000, function () { //fade out the 3 after fadein and start $(this).fadeOut(2000); }).promise().done(function () { if ($three.last().nextAll(':lt(3)').length) { //Same function, next 3 items fadeInSequence($three.last().nextAll(':lt(3)')); } else { //Same function, from the b

Categories : Jquery

Kendo UI Web - Drop-down list, different background color on each list item.
There is one easy part and one difficult part. The easy is getting the background the difficult is making it look nice. Easy, define a template for rendering each list item: <script id="template" type="text/kendo-tmpl"> <div style="background-color: #= text #;">#= text #</div> </script> And then define your ComboBox as: $(document).ready(function () { $('#combobox').kendoComboBox({ template : $("#template").html() }); }); but this is likely to do not be as nice as you want since before the <div> from my template there is a <li> introduced by KendoUI and unless you want to start playing with it, you might consider just displaying a color square with the item color. You can do something like: Start defining a CSS for the color

Categories : CSS

Linq how to query a list of items for a combined list of a child collection based on a property of the parent item
You may just want to group the invoice headers by the group: var groups = invoiceHeader.GroupBy(ih => ih.Group); Then you can access the lines of the groups: foreach(var group in groups) { Console.WriteLine("Group " + group.Group); Console.WriteLine("Lines:"); Console.WriteLine(string.Join(", ", group.SelectMany(h => h.InvoiceHeader.InvoiceLines))); } Output would be something like Group A Lines: invoice1, invoice2, invoice3, invoice4 Group B Lines: invoice5, invoice6, invoice7, invoice8

Categories : C#

Add items with same date to sub list of item main list
You can try something like this, using linq var mySubList = lessons.Where(l => l.HOURstartDT == AddYourDataHere); mySubList.ForEach(item => { lessons.remove(item); }); Not sure I understand the full question, but this will be a start

Categories : C#

ValueError: list.remove(x): x not in list, item definitely exists
Instead of picking a random index from the list of snapshots, shuffle the list once and pop items from that shuffled list: shuffledSnapList = snapRoList[:] random.shuffle(shuffledSnapList) while shuffledSnapList: roSnapshot = shuffledSnapList.pop() By using a while loop testing against the list you are removing from, you guarantee the loop will terminate when the list is empty. Because the list is shuffled, the items are processed in random order.

Categories : Python

JQuery move list item to end of unordered list
Do you mean you want Item 5 always at the bottom? Your fiddle works, you forgot to include jQuery UI in the fiddle. jQuery('ul.itemExtraFieldslist').sortable({ stop: function(event, ui) { $(this).append($('li.price')); } }); Updated JSFiddle

Categories : Jquery

dropdown list on showing selected item from list
Just set your Dropdown Auto AutoPostBack to False. <asp:DropDownList ID="DropDown" runat="server" DataTextField="DisplayName" DataValueField="ID" AutoPostBack="False" DataSourceID="Sections"> </asp:DropDownList> <asp:SqlDataSource ID="Sections" runat="server" ConnectionString="<%$ ConnectionStrings:MyConnection %>" SelectCommand="SELECT e.DisplayName, e.ID , e.GUID FROM .. e INNER JOIN .. re ON e.ID = re.anID AND re.otherID = 1"> </asp:SqlDataSource> Check this Url based on your new query: Populate one dropdownlist based upon action of another dropdownlist Best Regards

Categories : C#

search an item of sublist in another list of list by position
Probably, you should try this: // This will only work, if smalllist is shorter than biglist SCRIPT: biglist = [['A'], ['C', 'T'], ['A', 'T']] smalllist = [['C'], ['T'], ['A', 'T']] for i, group in enumerate(smalllist): for item in group: if item not in biglist[i]: biglist[i].append(item) DEMO: print(biglist) # [['A', 'C'], ['C', 'T'], ['A', 'T']]

Categories : Python

How to get a list of checked item from Check List VB. Net Winform
How about using CheckedItems collection instead? EDIT: dim itemChecked as Object For Each itemChecked In checkList_Facility.CheckedItems MsgBox(itemChecked.ToString()) Next

Categories : Vb.Net

Can List.Distinct() apply to the list type of List>?
That's because List<T> has no Equals and GetHashCode implemented, so standard reference comparison is being performed. And it returns false, because you have two separated lists. You can write your own IEqualityComparer<List<string>> implementation and provide it as Distinct method parameter. Within the comparer you can use Enumerable.SequenceEqual) method to check if lists has the same content.

Categories : C#

Find item in list inside list
There is a number of ways to write it more compactly: 7 in (x[0] for x in a) # using a generator to avoid creating the full list of values or using some standard library modules: import operator import itertools first_elem = operator.itemgetter(0) 7 in itertools.imap(first_elem, a)

Categories : Python

How to find the ID of the next li (list item) within an ul (unordered list)
This seems very easy to accomplish: function getNext(id) { return $("#" + id).next("li").attr("id"); } Demo: http://jsfiddle.net/QKRrM/

Categories : Jquery

adding item to a list then have list appear in a Combobox
EDIT: I am going to assume this question is mis-tagged as WPF and is really about winforms in which case my answer doesn't make sense profselect.ItemsSource = datalist; (not DataSource) and indeed it probably should be outside the loop

Categories : C#

How to select a particular list item from a list? (like the sixth or second etc.)
You can use the .eq() function for that. $('#box li').eq(2).click(); Note that the first index is zero, so if you wanted the second element it'd be element 1.

Categories : Javascript

How to check if any item in a list occurs in another list?
You can use any here: any will short-circuit and will stop at the first match found. >>> listA = ["A","B","C"] >>> listB = ["B","D","E"] >>> stringB = "There is A loud sound over there" >>> lis = stringB.split() >>> any(item in listA or item in lis for item in listA) True If listBis huge or the list returned from stringB.split() is huge then you should convert them to sets first to improve complexity: >>> se1 = set(listB) >>> se2 = set(lis) >>> any(item in se1 or item in se2 for item in listA) True If you're searching for multiple words inside that string then use regex: >>> import re >>> listA = ["A","B","C"] >>> listB = ["B","D","E"] >>> stringB = "There is A loud sound ov

Categories : Python

Remove list item and add them to and unordered list
Don't remove the slice or else it deletes it from the dom. First make the slice selection as you did and assign it to a variable, then append that variable to the UL. Then you can remove whatever you want from the DOM. var myItemsGreaterThan5 = $('li').slice(5); $( "ul" ).append( "<li>More +</li>" + myItemsGreaterThan5 ); myItemsGreaterThan5.remove();

Categories : Jquery

Move First 10 List Items to Another Item List
Try this: NewItems.AddRange(OldItems.Take(10)); OldItems = OldItems.Skip(10).ToList(); alternate: NewItems.AddRange(OldItems.Take(10)); OldItems.RemoveRange(0,10); Take will take x first items from your list look here. Skip will skip x elements from your list look here. RemoveRange is an alternative option if you will use lists reference. As Matthew said second option won't create new list and do removal in-place, so it's prefered.

Categories : C#

How to add List containing item of type List ,int,string into another List
Use the power of LINQ: var B = A.GroupBy(x => new { x.Name, x.EngineType }) .Select(g => new Car { Name = g.Key.Name, EngineType = g.Key.EngineType, Months = g.SelectMany(x => x.Months.Select((y,i) => new { i, y = int.Parse(y) })) .GroupBy(x => x.i) .OrderBy(g2 => g2.Key) .Select(g2 => g2.Sum(x => x.y).ToString()).ToList() }).ToList();

Categories : C#

Python: given a list of lists, create a list ordered by the number of occurrences in inner list
You can use collections.Counter to keep a counter for each element inside each sublist. Something like this, >>> from collections import Counter >>> lst = [['a','b','c'], ['a'], ['a','b']] >>> counts = Counter() >>> for sublst in lst: ... for ele in sublst: ... counts[ele] += 1 ... >>> [ele for ele, _ in counts.most_common()] ['a', 'b', 'c']

Categories : Python

In a responsive site design, how do i put a list below other list that contains a sub-list without overlap the main lists
Pretty simple : remove the fixed height of your li.menulinks, add a "header" (green rounded rectangle with 35px height) div as first child of the li and...you're set ! Look at this fiddle : http://jsfiddle.net/32pga/ <div class="sitemap"> <div class="row-fluid"> <ul> <li class="menulinks"> <div class="menulinks-header"></div> <ul> <li class="submenulinks"> <div>Test 1</div> </li> <li class="submenulinks"> <div>Test 2</div> </li> <li class="submenulinks"> <div>Test

Categories : HTML

iterating list of array-list and assigning each list to single dynamically created div in jsp
Try this, <c:forEach var="user" items="${userList}" varStatus="count"> <div id="col${count}"> <c:out value="${user.name}"/> </div> </c:forEach>

Categories : Java

Trying to input data from a txt file in a list, then make a list, then assign values to the lines
[] implies a list. '' implies a string. allt = ['mw91 42.927 -72.84 2.8'] allt is a list that contains a string: allt[0] --> 'mw91 42.927 -72.84 2.8' allt[0][2] --> '9' allt.split() --> ['mw91', '42.927', '-72.84', '2.8'] allt.split()[2] --> '-72.84' #This is still a string. float(allt.split()[2]) --> -72.84 #This is now a float.

Categories : Python

How to make List of Unique data from multiple List containing duplicate values
To not use loops, use recursive calls of functions. You can use a hash array, or an object and set its properties with your values, use "true" value for simplicity. When you override, its not a problem, it will just get re-set as true. Afterwards, you loop through the hash array or object and all its properties are unique (and all have the value true). If you have a particular language of programming, mention it as a comment, I might give you the function to do it.

Categories : Java

Get list of values from a nested Python data-structure using a list comprehension?
Try following: >>> from collections import namedtuple >>> >>> class P(namedtuple('_P', 'val back')): ... def __iter__(self): ... while self: ... yield self.val, self.back ... self = self.back ... >>> q = P(val=15, back=P(val=11, back=P(val=9, back=P(val=6, back=P(val=2, back=P(val=0, back=None)))))) >>> [val for val, back in q] [15, 11, 9, 6, 2, 0]

Categories : Python



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.