w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
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

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

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

Add a unique ID to a menu item list
jQuery: You can use .each and the incrementing index in the callback function: $("#nav-main-menu li").each(function(index) { $(this).attr("id", "id" + index); }); Each li will now have an ID starting at id0 to however long the list is.

Categories : Javascript

How to order a LinQ result set created by a list of ID and order it use existing order of the list
use OrderByDescending IQueryable<Post> pp = myDataEntity.Posts.Where(p=>IDs.Contains(p.ID)) .OrderByDescending(p => p.ID)

Categories : Linq

Get the order of list item in jquery sortable
The documentation of toArray of Soratble [link here] clearly says that it Serializes the sortable's item id's into an array of string. That means, you should use your sortable elements with an id for each one <ul id="sortable2" class="connectedSortable"> <li id="1" class="ui-state-highlight">Item 1</li> <li id="2" class="ui-state-highlight">Item 2</li> <li id="3" class="ui-state-highlight">Item 3</li> <li id="4" class="ui-state-highlight">Item 4</li> <li id="5" class="ui-state-highlight">Item 5</li> And now when your code var idsInOrder = $("#sortable2").sortable('toArray'); alert(idsInOrder); will definitely output an array.

Categories : Javascript

Recursive function in R to find unique rows of a list of data tables
Add an id column to each data.table t1$id=1 t2$id=2 t3$id=3 then combine them all at once and do a unique using by=. If the data.tables are huge you could use setkey(...) to create an index on id before calling unique. tall=rbind(t1,t2,t3) tall[,unique(col1,col2),by=id]

Categories : R

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

generating unique ordered non duplicate combinations in java for a list of list
1: Is this homework? 2: How many lists do you anticipate using as a maximum? Basically... there's not going to be some sort of magical way to do this... you're going to have to check to see if the string you're building already contains the letter you're considering adding, and that's what you want to optimize -- checking if your String already contains a letter. If you're doing this for homework, I think you can use a String.contains( 'a' ) || String.contains( 'A' ) to see if the String already contains a certain letter ('a' in this case). I'll leave the rest of it to you. Note that this is an O(n^2) operation. If you're doing this for a more... industrial... application, then I see another option. If you're going to have a large number of String lists, then you'll probably want to

Categories : Java

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

Using Java's built-in Set classes to count EACH(keyword) unique element in List values from a list
You are looking for Map<String, Integer> data structure, not Set Something like for(iterating over something){ Integer count =map.get(value); if( count == null){ map.put(value, 1); } else{ count++; map.put(value, count); } } Map is the data structure that maps unique to value

Categories : Java

Reorder EKReminder in a list
So, EKCalendarItem objects have calendarItemExternalIdentifier which is unique to the event across devices. You can use this to your advantage for this ordering strategy. Every time you fetch events from the calendar API, keep track of their calendarItemExternalIdentifier in whatever persistence store you choose (Core Data, SQLite, Property Lists, etc...) and also keep track of it's order. So if you used Core Data you might have an entity with two attributes, calendarItemExternalIdentifier and order. Now whenever you present the events to the user, query the persistent store for order of each event and display accordingly. If new events come in, find the highest order and increment from there. When the user re-orders, set the order key for the appropriate record in your persistent store.

Categories : IOS

Reorder list by a property I don't have
If you're happy to do this in-process (rather than as part of the query) you can use: var orderedChannelNames = new[] { "BBC2", "BBC1", "ITV", ... }; var sorted = unsorted.OrderBy(ch => orderedChannelNames.IndexOf(ch.ChannelName)); Alternatively, if you know all the channels in your list will be present: var map = unsorted.ToDictionary(ch => ch.ChannelName); var sorted = orderedChannelNames.Select(name => map[name]);

Categories : C#

Getting unique values from a list of objects with a List as a property
If I understand, you want a list of all of the unique certifications among all of the employees. This would be a job for SelectMany: var uniqueCerts = empList.SelectMany(e => e.Certifications).Distinct().ToList();

Categories : C#

Sorted/unique list of object instances from a larger list?
One way to do this is using itertools.groupby(): import itertools x3 = [next(g) for k, g in itertools.groupby(x2, lambda x:(x.a, x.b))] This picks the first element of each group with the same key.

Categories : Python

PHP: Random list of 52, so when repeated it's unique from the previous list?
Well there are is a small problem with the assumptions you have Rule 1 The overall goal is that each list has no relationship or common pattern to it's previous list. Rule 2 The rule is that the first element of the list and the last element can't be the start and end elements from the previous list. Those two contradict each other. First there may be no relationship, so random. So as you said shuffle (did not look at is I take your word). But the second one needs to know about the previous one. What contradicts with your previous rule. But what you could do is have the first and last element of the previous draw (the previous 52). Then you shuffle the current draw. If the first and/or last element are the same, draw again until no match is found. Also I think the word for this is

Categories : PHP

jQuery - Reorder list by changing textbox value
Here's a quick way to do this (without error checking): $('input').keyup(function () { var start = $(this).index('input'); var target = $(this).val() - 1; if (target < start) $(this).parent().insertBefore($('li').eq($(this).val() - 1)); if (target > start) $(this).parent().insertAfter($('li').eq($(this).val() - 1)); }); jsFiddle example Note that is you want to renumber the inputs after the change, add this line to the end of the function $('input').each(function(){$(this).val($(this).index('input')+1)});

Categories : Jquery

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: 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

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

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

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

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

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 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

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#

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

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#

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#

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

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

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#

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

Get unique list of ids from object list
You can add the id's as keys to a dictionary and obtain back the keys of it: d = {} for item in items: d[item.id] = item print d.keys() Now, d.values() contains the items which have the unified ids. As long as no two different items have the same id the above is lossless. Contrasting with other solutions (at the time of writing) this also provides a good mapping between the id and the item with the specified id.

Categories : Python

Check if one list contains all items from another list in order
Here's a quick way: var equal = listA.Count - listB.Count < 0 ? false : Enumerable.Range(0, listA.Count - listB.Count).Any(i => listA.Skip(i).Take(listB.Count).SequenceEqual(listB)); However, I'd prefer to use an extension method like this: public static bool ContainsSequence<T>(this IEnumerable<T> outer, IEnumerable<T> inner) { var innerCount = inner.Count(); for(int i = 0; i < outer.Count() - innerCount; i++) { if(outer.Skip(i).Take(innerCount).SequenceEqual(inner)) return true; } return false; } which you can call like: var equals = listA.ContainsSequence(listB); And here's a more efficient version of the same extension method specific to List<T&g

Categories : C#



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