w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to insert nested lists (or nested block elements) into RichTextBlock?
Ok Ill start with silverlight. There was a TreeView Control in silverlight that would have exactly solved your problem. Link to tree view example But since we already know that winRt is a subset of API's these controls have been removed for metro app. More over microsofts design policy regarding the Type Of scenario you are mentioning has changed to : Semantic Zoom For Metro Apps So i advise if your app requirement is like that Either go with the richtextbox or use Grids with Rows and columns Which ever suits your coding best. One more way is to use third party library for tree structure . Syncfusion tree control Syncfusion has a tree control you can try out in the Demo. Even there are more third party tool but none are free not even he above one. Please Let me know if any more co

Categories : HTML

Deserialize deep-nested arrays
It seems there's no built-in way of de-/serializing deep-nested json into anything other than JObject/JArray. So I use strings instead. I suppose one could write a converter to handle everything, however not needed in my case. public class NestedArrayConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { if (value.GetType() == typeof(List<string>)) { var list = (List<string>)value; writer.WriteStartArray(); foreach (var str in list) writer.WriteRawValue(str); writer.WriteEndArray(); } else { writer.WriteValue(value); } } public override object ReadJson(JsonReader reader,

Categories : C#

Jackson - Deserialize nested JSON
I see couple of problems in your code. First thing is that you don't have report attribute in your Response class, which is required as per the json structure you have shown. Secondly you need to provide the getters and setters in your bean classes as those will be used by the jackson for marhsalling and unmarshalling of json/object.

Categories : Java

RestSharp deserialize deeply nested XML document
XML is case-sensitive in the deserialization process. To quickly get around this you can try XML = XML.Replace("COUPON", "Coupon"); etc for each of your element names. If you're going to be processing many different xml files then it will be worth finding something that will do that nicely for you. nb, you could also change the name of your property in Template from Coupon to COUPON

Categories : C#

Struts 1.1 nested and in combination
Use <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> and the code will look like <c:choose> <c:when test="${element.method1 == true}"> <c:choose> <c:when test="${element.method2 == true}"> <span style="color:green;"><c:out value="${element.prop1}/></span> </c:when> <c:otherwise> <span style="color:red;"><c:out value="${element.prop1}/></span> </c:otherwise> </c:choose> </c:when> <c:otherwise> <span style="color:black;"><c:out value="${element.prop1}/></span> </c:otherwise> </c:choose>

Categories : Java

JSON Deserialization Despair (unable to deserialize nested types)
I haven't done what you are doing before, but judging by the documentation, I'd assume the following would work: List<Type> types = new List<Type>(); types.Add(typeof(Person)); types.Add(typeof(Language)); types.Add(typeof(Secretary)); DataContractJsonSerializer dc = new DataContractJsonSerializer(typeof(PeopleObject), types); PeopleObject p = (PeopleObject)dc.ReadObject(response); You basically need to tell the Serializer all the types it may encounter while serializing/deserializing your object.

Categories : C#

Cannot deserialize the current JSON array (e.g. [1,2,3]) into type with complex and nested objects
According to your JSON data, the objects that you need to map to have to look like this (unless you have your own JsonDeserializer of course): public class Banner { public string LocationCodeString { get; set; } public int LocationCodeInt { get; set; } public string MediaUrl { get; set; } } public class CampaignWithChosenProposal { public List<Banner> Banners { get; set; } public string Code { get; set; } public string CustomerInstruction { get; set; } public string InfoLink { get; set; } public string LobbySubTitle { get; set; } public string LobbyTitle { get; set; } public string MoreText { get; set; } public int NumOfColumns { get; set; } public int NumOfRows { get; set; } public string OriginString { get; set; } public int

Categories : C#

Knockout.js nested lists
I was able to get the formatting I wanted with the following html markup: <div id="tourneys_in_progress"> <h2>Open Tournaments</h2> <div id="tourneys"> <ul data-bind="template: { name: 'tourneyTemplate', foreach: tourneys.CurrentTournaments }"></ul> <script id="tourneyTemplate" type="text/html"> <li class="tourneys"> <div class="tourney"> <div data-bind="text: 'TournamentType: ' + TournamentTypeString"></div> <div data-bind="text: 'Number of Rounds: ' + Rounds" ></div> <div data-bind="text: 'Boards: ' + Boards" ></div> <div data-bind="text: 'Players per Board: ' + PlayersPerBoard"></di

Categories : Knockout Js

Nested lists and percentages
I'm interested by what you are trying to achieve. It's not something I've ever had to do, but you have brought up an interesting point. I also think you may have mis-understood the way some of the inheritance works. Just because you put relative positioning on an element doesn't change the way the sub elements get their widths. Percentage widths always get their widths based on their parent element, whether it's relative positioned or whatever. In most cases the parent fills the space of it's parent, etc. There is definitely a certain amount of 'zen' that needs to be grasped when it comes to CSS and yes continuing in web-development could cause the loss of hair! Buy a stress ball and you should be ok :) As for heights that's a different story as it's buggy as hell and generally doesn't pic

Categories : HTML

Nested Lists in MVC 4 page
From within any view, you can call an action from any controller. As an example, the Razor ActionLink helper allows you to pass a controller name along with the method name from that controller: @Html.ActionLink("Link text, "Action Name", "Controller Name") And a form that posts to a different controller than the one that rendered the view: @Html.BeginForm("Action Name", "Controller Name", FormMethod.Post, new { enctype = "multipart/form-data" })) { // Form fields } Whether or not you want to do this depends on the overall design of your application. It may be simpler to create a "RefundVoucher" ViewModel that encapsulates the data that you need from your Refund and Voucher Models and create a controller and strongly-typed views for that.

Categories : Asp Net Mvc

Indexing nested lists in R
The lists would be extracted with [[ and the matrices (not lists) with [,] indexing, but you need to give the functions something to work with. (At the moment you are not.) So if you wantend the 4h matrix and the i,j values were 10 and 3 this would deliver that value: myNestedList[[4]][10,3] The evaluation proceeds left to right. Wrapped in a function and assuming from context that you only wanted the i-th column (which is a bit confusing since i usually refers to rows): pull.ith.col.from.nth.mat <- function(lis, n, i) lis[[n]][ , i]

Categories : R

Nested Lists in PHP and MySQL
query SELECT a.item, b.item, c.item FROM TOP_LEVEL a JOIN SECOND_LEVEL b ON b.level = a.level JOIN THIRD_LEVEL c ON c.level = b.level ORDER BY a.item, b.item, c.item code <?php $q = "SELECT a.item, b.item, c.item FROM TOP_LEVEL a JOIN SECOND_LEVEL b ON b.level = a.level JOIN THIRD_LEVEL c ON c.level = b.level ORDER BY a.item, b.item, c.item "; ...... your database stuff...... ...... resulting array should be two-dimensional `$items` ...... $c = 0; echo "<ul> "; while ($c < count($items)) { for ($j = 0; $j < count($items[$c][0]); $j++) { echo "<li>$items[$c][0] "; echo "<ul> "; for ($k = 0; $k < count($items[$c][1]); $k++) { echo "<li>$items[$c][1] "; echo "<ul> "; for ($i = 0; $i &

Categories : PHP

A program to mutate Nested Lists
You can use recursion: def capitalize_list(t): N = [] for i in range(len(t)): if type(t[i]) == str: N.append(t[i].capitalize()) if type(t[i]) == list: N.append(capitalize_list(t[i])) return N Output: ['A', 'B', ['C', 'D'], ['E'], 'F']

Categories : Python

Lists with multiple 'nested' items
You have to access the list elements with [[ instead of [: for(i in cats){ l1[[i]][1]<-"hello" };l1 for(i in cats){ l1[[i]][2]<-"goodbye" };l1 > l1$red[1] [1] "hello" > l1$red[2]

Categories : R

nested for loops in python with lists
Use the zip function, like this: list1=['a','b'] list2=['y','z'] for i, j in zip(list1, list2): print(i, j) Output: ('a', 'y') ('b', 'z')

Categories : Python

C++ Data Structure for Nested Number Lists
A Trie is likely to be the most efficient structure for something like this. You can find an overview on what Trie's are here. Essentially Trie's store values where there are liable to be many overlaps early in the values (like strings or sequences of numbers), by only storing each value at each position once. The diagram you drew almost exactly depicts a Trie.

Categories : C++

iterate python nested lists efficiently
The code you've shown doesn't make a great deal of sense. Here's what it does: Iterate through the sequence 'in', 'out', assigning each of those two strings in turn to the variable iter (masking the built-in function iter() in the process) on its two passes through the loop. Completely ignore the value of iter inside the loop. Assign the result of myhttp() to the variable netdata on each pass through the loop. Completely ignore the value of netdata, and instead attempt to print the undefined variable data on each pass through the loop. It's possible, given the nested list you describe, that you want something like this: for t, f in myhttp(): print t print f # ... or whatever you want to do with those values.

Categories : Python

Adding two lists and getting XML output in nested form
You should create an object which contains an application and a list of environments, like ApplicationWithEnvironments. List<ApplicationWithEnvironments > AppWithEnvlist = new ArrayList<ApplicationWithEnvironments >(); for(ApplicationDTO d: allApplication) { ApplicationWithEnvironments appWithEnv = new ApplicationWithEnvironments(); Application a = new Application(); a.set... appWithEnv.setApplication(a); for(EnvironmentDTO en: d.getEnvironment()) { Environment e = new Environment(); e.set... appWithEnv.addEnvironment(e); } AppWithEnvList.add(appWithEnv); } ArrayList<MyModel> obj= new ArrayList<MyModel>(); MyModel mm = new MyModel(

Categories : Java

MVC4 Razor syntax one-to-many nested lists
You are going to want to use linq's groupby to do that. @{ foreach (var parent in Model.GroupBy(m => m.ParentTable.DisplayName)) { <div> @parent.Key @foreach( var itm in parent ) { <ul> <li> <span> @itm.City </span> <span> @itm.State</span> </li> </ul> } </div> } }

Categories : Linq

JSON serializer with nested object lists
Turns out you don't need to use a serializer at all. You just return type object. public object NavigationItems() { using (TTConnection connection = new TTConnection("ClientDb")) { if (MySession.Current.MyClub == null) return USER_ERROR; MiddleTier.WebNavigation.WebNavigationGenerator gen = MySession.Current.NavGenerator; List<NavigationElement> list = gen.GetNavigation(); return list; } }

Categories : C#

MVC 4 binding nested list of lists result
http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx It's an old article, but it still applies. I had this exact problem, but basically due to the model binding system you need to use an explicit for loop instead of a foreach loop, and reference your elements by their index. @using (Html.BeginForm("Edit", "Person", FormMethod.Post, new { id = "validate-form", @class = "block-content form" })) { Html.AntiForgeryToken() Html.HiddenFor(x => x.PersonID) for (int i = 0; i<Model.Tabs.Count; i++) { Html.EditorFor(x => Model.Tabs[i]) } <input class="close-toolbox button" type="submit" value="Save"> }

Categories : Asp Net Mvc

Nested Json Lists formatting incorrectly
The issue is not really in removing the u from the start of those strings. The easiest way to do this is to import the json module and call json.dumps(checklist.json()['list']). It will do the right thing for you. The strings the json module returns are unicode objects (and are represented in the repr) as unicode literals. To "remove" them you need to handle the unicode strings better and this is the easiest way that will result in the least hair pulling and most forward compatibility with python 3.

Categories : Python

Nested select lists and loading information
Its because use change the html so event cannot work you need to add event listener every time like this function bindEvent(){ $('.standing_leagues').on('change',function(){ var standing_id = $(this).children(":selected").attr("id"); alert(standing_id); }); } See Demo Call that function on every time you change the html of .leagues class

Categories : Jquery

Linq select common subset of nested lists
You can use Enumerable.Intersect, for example: IEnumerable<string> commonSubset = allDevices.First().Interfaces; foreach (var interfaces in allDevices.Skip(1).Select(d => d.Interfaces)) { commonSubset = commonSubset.Intersect(interfaces); if (!commonSubset.Any()) break; } DEMO If you want to reuse it you could make it an extension method: public static IEnumerable<T> CommonSubset<T>(this IEnumerable<IEnumerable<T>> sequences) { return CommonSubset(sequences, EqualityComparer<T>.Default); } public static IEnumerable<T> CommonSubset<T>(this IEnumerable<IEnumerable<T>> sequences, EqualityComparer<T> comparer) { if (sequences == null) throw new ArgumentNullException("sequences"); if (!sequen

Categories : C#

Multidimension array versus nested lists in python
Python does not have a multidimensional array type. It only has lists. numpy (a 3rd-party Python extension) does have array types, and these serve a specialized function within that library, namely fast C-based mathematical operations on homogenous sequences. With the standard Python list type, putting one inside the other creates a nested structure that can be used to model a multidimensional structure. You nest the [index] item access, [1][42] first retrieves the second element of the outer list, then the 43rd element of that second element. numpy arrays are specialist structures that explicitly model multiple dimensions as part of the main type, rather than nesting arrays inside arrays, and that means they can support addressing of multiple dimensions in the [index] syntax, where ind

Categories : Python

Combinations in of nested lists in python based on a one key attribute
>>> from itertools import combinations >>> nums = [[0,25], [1,54], [2,76], [3,13], [4,79]] >>> list(combinations(nums, r=2)) [([0, 25], [1, 54]), ([0, 25], [2, 76]), ([0, 25], [3, 13]), ([0, 25], [4, 79]), ([1, 54], [2, 76]), ([1, 54], [3, 13]), ([1, 54], [4, 79]), ([2, 76], [3, 13]), ([2, 76], [4, 79]), ([3, 13], [4, 79])] As the name implies, itertools.combinations returns an iterator (yields combinations lazily), you must consume the iterator with the list(...) constructor to obtain your list. Usually the iterator is preferable though, since you probably only need to iterate over the combinations. for a, b in combinations(nums, r=2): pass Don't construct a list if you don't need to store the result.

Categories : Python

Nested lists: how to define the size before entering data
Your approach seems a bit complicated to me. You might want to consider using something like a look-up table that contains the combination of cases for each element: Example id <- seq(2*3*3*4*2*3*3) # a vector of identification values #create a lookup table lut <- cbind(id=id, expand.grid(lev1=seq(2), lev2=seq(3), lev3=seq(3), lev4=seq(4), lev5=seq(2), lev6=seq(3), lev7=seq(3))) list.obj <- vector(mode="list", nrow(lut)) #optional addition of names names(list.obj) <- paste(lut$lev1, lut$lev2, lut$lev3, lut$lev4, lut$lev5, lut$lev6, lut$lev7, sep=".") head(list.obj) #fill in list with data for(i in seq(list.obj)){ matching <- i #here you can have some sort of case matching for filling in elements of the list list.obj[[matching]] <- runif(10) } head(list.obj)

Categories : R

How to find elements that are common to all lists in a nested list?
You can use reduce and set.intersection: >>> reduce(set.intersection, map(set, nested_list)) set([2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0]) Use itertools.imap for memory efficient solution. Timing Comparisons: >>> lis = [[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0], [2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0], [1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0], [2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0]] >>> %timeit set.intersection(*map(set, lis)) 100000 loops, best of 3: 12.5 us per loop >>> %timeit set.intersection(*(set(e) for e in lis)) 10000 loops, best of 3: 14.4 us per loop >>> %timeit reduce(

Categories : Python

MVC4 Not Posting Object With Nested Recursive Lists
The list is rendering an item for each node, but it is not rendering the name attribute for each node properly. Razor handles lists by using the name attribute to create arrays when the inputs are posted back and the model re-created. Eg List<Foo> AllMyFoos { new Foo { Id = 1 }, new Foo { Id = 2 }, new Foo { Id = 3 }} Would be rendered (as per your example above) like this: <input type="text" name="AllMyFoos[0].Id" /> <input type="text" name="AllMyFoos[1].Id" /> <input type="text" name="AllMyFoos[2].Id" /> Under the hood the model binding in Razor and MVC then recreates the list of Foo objects and passes it to your controller method. The issue with your recursive method is that when you call it with the list of child nodes, the index of each child node i

Categories : Asp Net Mvc

Python printing Formatted text with lists nested in dict
Something like this: processors_info = " ".join(machine_info['processors']) print "Processor(s): {}".format(processors_info) Demo: >>> info = ['processor_1_info', 'processor_2_info'] >>> processors_info = " ".join(info) >>> print "Processor(s): {}".format(processors_info) Processor(s): processor_1_info processor_2_info Another way using string formatting: info = ['processor_1_info', 'processor_2_info', 'processor_3_info'] #info = machine_info['processors'] for your code. print "Processor(s):{:>20s}".format(info[0]) for item in info[1:]: print "{:>33s}".format(item) output: Processor(s): processor_1_info processor_2_info processor_3_info

Categories : Python

Python Operations (Intersection, Union, Duplicate) with nested Lists/Tuples possible?
Use sets: >>> seen = set() >>> s1 = [x for x in a if x[0] not in seen and not seen.add(x[0])] >>> seen = set() >>> s2 = [x for x in b if x[0] not in seen and not seen.add(x[0])] >>> s1 [(1, 2), (2, 3), (4, 5)] >>> s2 [(5, 2), (6, 3), (4, 5), (1, 9)] Union: >>> from itertools import chain >>> seen = set() >>> [x for x in chain(s1,s2) if x[0] not in seen and not seen.add(x[0])] [(1, 2), (2, 3), (4, 5), (5, 2), (6, 3)] Intersection: >>> se1 = set(x[0] for x in s1) >>> se2 = set(x[0] for x in s2) >>> inter = se1 & se2 >>> inter set([1, 4]) >>> seen = set() >>> [x for x in chain(s1,s2) if x[0] in inter and x[0] not in seen

Categories : Python

How to handle multidimensional output with (nested) lists using the ZendDbTableGateway with a mapper in Zend Framework 2?
What you are trying to accomplish has nothing to do with the TableGateway-Pattern. The TableGateway-Pattern is there to gain access to the Data of one specified Table. This is one of the reasons why in ZF2 you no longer have the option to findDependantRowsets(). It's simply not the TableGateways Job to do so. To achieve what you are looking for you have pretty much two options: 1. Joined Query You could write a big query that joins all respective tables and then you'd manually map the output into your desired JSON Format. 2. Multiple Queries A little less performant approach (looking at the SQL side of things) but "easier" to "map" into your JSON Format. To give some insight, Doctrine would go with the multiple query approach by default. This is mostly (i guess!) done to provide feat

Categories : PHP

JQuery selector for finding a nested span within a nested class is not working
I don't see any problem with your code at the moment, let's reformat it a bit: var tabs = $('.collapse').not('.in'); console.log("tabs.length: " + tabs.length); tabs.each(function () { var $this = $(this), thisErrors = $this.find('.field-validation-error'), thisId = '#' + $this.attr('id'); console.log("current tab ID: " + thisId); console.log("number of errors: " + thisErrors.length); if (thisErrors.length) { $(thisId).collapse('show'); } }); Or working fiddle: http://jsfiddle.net/Rq8y7/ Does it work now? And what's the debug message in console after you run above code?

Categories : Jquery

How can I bind data from nested List<> objects to nested ListView controls?
You can bind the datasource of your inner list view to a property of the items bound to your outer listview. However, to do that the inner listview as to be in the itemtemplate of the outer listview. See the code below and note the DataSource='<%# Eval("Labels_color") %>' attribute for the inner list view. <asp:ListView ID="ListView_Orp_Results" runat="server" ItemPlaceholderID="itemPlaceholder"> <LayoutTemplate> <div id="outer_result_container"> <div id="itemPlaceholder" /> </div> </LayoutTemplate> <ItemTemplate> <div id="result_photo">...</div> <div id="result_category">...</div> <div id="result_detector">...</div> <div id="inner_result_container" runat="server"

Categories : Asp Net

Parsing a flattly-written nested text template into a usable nested data structure for N levels
Replaces each ">" with a tab. Output is pretty much exactly as your brute force output. (file.txt is your template file as above) test = open("file.txt", "r") for line in test: print line.replace(">", " ") #print line

Categories : Python

MySQL - Reference main query in nested select (need to be nested)
This cannot work. SELECT clause is always evaluated at the end of the execution chain, @teamg_id variable will always be 0 in the nested subquery. Try this query, it is not tested (I can't see your data, playing whith sample data always helps), but probably it gives desired results. I commented out some parts and add one join condition. /* SET @teamg_id := 0; */ SELECT /* @teamg_id := player.team_id, */ player.team_id AS player_team, event.local_team_id AS local_team, event.visitor_team_id AS visitor_team, action.unique_id AS action_id, action.player_id AS player_id, player.name AS player_name, playerindex.rank AS player_pos, playerindex.ses_var_nest AS ses_var_nest FROM er_players player

Categories : Mysql

How Can I Convert Nested YAML to nested Arrays and OpenStructs in Ruby
There is the solution (https://github.com/jsuchal/hashugar) i often use. opts = Hashugar.new({:a => 1, 'b' => {:c => 2, :d => [3, 4, {:e => 5}]}}) But you also need to do: opts.b.d.last.e I do not understand how do you want to name array's getters. As Arup Rakshit sayed: give us yaml example and expected output or behavior.

Categories : Ruby

nested json with jQuery: create List of nested item
Your problem is that institut is an array containing a single object, so you can reference that single object using institut[0]. This will work: $.each(data.fakultaeten, function (key, value) { var mother = "<li id='first'>" + value.name + "<ul>"; $.each(value.institut[0], function (key1, value1) { alert(key1); }); }); Here is a working example

Categories : Jquery

Avoiding nested each loops when handling nested JSON data
JSON is "just" javascript object literals. You can skip the jQuery call, and just reference the objects and arrays directly after you parse it. obj.custom_sql_rule[0].something_else[0]; of course, your JSON is a bit oddly-formed. If at all possible, don't arbitrarily mix objects {} and arrays [] . Use the latter when you have lists of identical objects or primitive data, and the former when you have named properties. And once you have a valid javascript object, you can just iterate through its properties. for(var sqlProp in jsonObj) { if(jsonObj[sqlProp].error) { errorsContainer.append("<div>" + jsonObj[sqlProp].error + "</div>"); } }

Categories : Javascript

nested attributes, passing current_user.id to nested model
'current_user' is a devise helper method. it can be accessed in controllers n views directly. if i m not wrong, only the new answer should have the current_user.id Old answers should not be updated. u can do this as f.fields_for :answers, @question.answers.build do |a| a.hidden_field :user_id, :value => current_user.id a.submit

Categories : Ruby On Rails



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