Search Results

Search found 13450 results on 538 pages for 'recent items'.

Page 77/538 | < Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >

  • WPF binding problem

    - by Lolo
    I've got problem with binding in XAML/WPF. I created Action class witch extends FrameworkElement. Each Action has list of ActionItem. The problem is that the Data/DataContext properties of ActionItem are not set, so they are always null. XAML: <my:Action DataContext="{Binding}"> <my:Action.Items> <my:ActionItem DataContext="{Binding}" Data="{Binding}" /> </my:Action.Items> </my:Action> C#: public class Action : FrameworkElement { public static readonly DependencyProperty ItemsProperty = DependencyProperty.Register("Items", typeof(IList), typeof(Action), new PropertyMetadata(null, null), null); public Action() { this.Items = new ArrayList(); this.DataContextChanged += (s, e) => MessageBox.Show("Action.DataContext"); } public IList Items { get { return (IList)this.GetValue(ItemsProperty); } set { this.SetValue(ItemsProperty, value); } } } public class ActionItem : FrameworkElement { public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(object), typeof(ActionItem), new PropertyMetadata( null, null, (d, v) => { if (v != null) MessageBox.Show("ActionItem.Data is not null"); return v; } ), null ); public object Data { get { return this.GetValue(DataProperty); } set { this.SetValue(DataProperty, value); } } public ActionItem() { this.DataContextChanged += (s, e) => MessageBox.Show("ActionItem.DataContext"); } } Any ideas?

    Read the article

  • Flex: Problem with CollectionEvent on ArrayCollection

    - by dasnervtdoch
    Hi there, got a reference to an arrayCollection and add event listener like this: collection.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChange); that´s fine. Now some other component does have the same reference and is adding items to and removing items from that collection. Each time the handler is called: private function onProjectPersonsChange(event:Event):void { if (event.kind == CollectionEventKind.ADD) { //do something } else if (event.kind == CollectionEventKind.REMOVE) { //do something //here is the problem: event.items.length = 0 } else { trace('CollectionEvent: kind not handled!'); } } Does somebody know why the removed item is not in 'items'? Thanks in advance!

    Read the article

  • Selecting rows distinctively

    - by noway
    Lets assume my database table structure is something like | items | weight | |============|==========| | item_1 | 50 | | item_2 | 90 | | item_2 | 45 | | item_2 | 60 | | item_3 | 40 | In the select statement, I want to show an item only for once with the highest weight also ordered by height. So the result should be : | items | weight | |============|==========| | item_2 | 90 | | item_1 | 50 | | item_3 | 40 | I tried something like SELECT DISTINCT items, weight FROM mytable ORDER BY weight DESC but it didn't work because the results are actually distinct. How can I make that selection?

    Read the article

  • Which of CouchDB or MongoDB suits my needs?

    - by vonconrad
    Where I work, we use Ruby on Rails to create both backend and frontend applications. Usually, these applications interact with the same MySQL database. It works great for a majority of our data, but we have one situation which I would like to move to a NoSQL environment. We have clients, and our clients have what we call "inventories"--one or more of them. An inventory can have many thousands of items. This is currently done through two relational database tables, inventories and inventory_items. The problems start when two different inventories have different parameters: # Inventory item from inventory 1, televisions { inventory_id: 1 sku: 12345 name: Samsung LCD 40 inches model: 582903-4 brand: Samsung screen_size: 40 type: LCD price: 999.95 } # Inventory item from inventory 2, accomodation { inventory_id: 2 sku: 48cab23fa name: New York Hilton accomodation_type: hotel star_rating: 5 price_per_night: 395 } Since we obviously can't use brand or star_rating as the column name in inventory_items, our solution so far has been to use generic column names such as text_a, text_b, float_a, int_a, etc, and introduce a third table, inventory_schemas. The tables now look like this: # Inventory schema for inventory 1, televisions { inventory_id: 1 int_a: sku text_a: name text_b: model text_c: brand int_b: screen_size text_d: type float_a: price } # Inventory item from inventory 1, televisions { inventory_id: 1 int_a: 12345 text_a: Samsung LCD 40 inches text_b: 582903-4 text_c: Samsung int_a: 40 text_d: LCD float_a: 999.95 } This has worked well... up to a point. It's clunky, it's unintuitive and it lacks scalability. We have to devote resources to set up inventory schemas. Using separate tables is not an option. Enter NoSQL. With it, we could let each and every item have their own parameters and still store them together. From the research I've done, it certainly seems like a great alterative for this situation. Specifically, I've looked at CouchDB and MongoDB. Both look great. However, there are a few other bits and pieces we need to be able to do with our inventory: We need to be able to select items from only one (or several) inventories. We need to be able to filter items based on its parameters (eg. get all items from inventory 2 where type is 'hotel'). We need to be able to group items based on parameters (eg. get the lowest price from items in inventory 1 where brand is 'Samsung'). We need to (potentially) be able to retrieve thousands of items at a time. We need to be able to access the data from multiple applications; both backend (to process data) and frontend (to display data). Rapid bulk insertion is desired, though not required. Based on the structure, and the requirements, are either CouchDB or MongoDB suitable for us? If so, which one will be the best fit? Thanks for reading, and thanks in advance for answers. EDIT: One of the reasons I like CouchDB is that it would be possible for us in the frontend application to request data via JavaScript directly from the server after page load, and display the results without having to use any backend code whatsoever. This would lead to better page load and less server strain, as the fetching/processing of the data would be done client-side.

    Read the article

  • Rails attribute alias

    - by Dr1Ku
    Hi, I was just wondering if it's possible to "rename" an association in Rails. Let's assume : # An ActiveRecord Class named SomeModelASubModel (some_model_a_sub_model.rb) class SomeModelASubModel < ActiveRecord::Base has_many :some_model_a_sub_model_items end # An ActiveRecord Class named SomeModelASubModelItem (some_model_a_sub_model_item.rb) class SomeModelASubModelItem < ActiveRecord::Base belongs_to :some_model_a_sub_model end At this point, calling some_model.items, where some_model is an instance of the SomeModelASubModel Class would trigger an undefined method error. What is the best practice for making this happen though, e.g. : # With a method_alias or something, would it be possible to : some_model = SomeModelASubModel.first # for instance items = some_model.items # For the reason stated, this doesn't work, one has to call : items = some_model.some_model_a_sub_model_items Is such a shorthand possible ? Thank you in advance !

    Read the article

  • FLEX, Tile container: how to better organize the children

    - by Patrick
    hi, I'm using as container for my LinkButtons. I would like to know 1) how can I remove the space between the items in my Tile container. 2) how can I set dynamic width for my items (at the moment they all have the same width regardless the width of the included component) 3) how can I avoid to display scrollbars if the items are not included in the container Thanks

    Read the article

  • Waiting for a subset of threads in a Java ThreadPool

    - by David Semeria
    Let's say I have a thread pool containing X items, and a given task employs Y of these items (where Y is much smaller than X). I want to wait for all of the threads of a given task (Y items) to finish, not the entire thread pool. If the thread pool's execute() method returned a reference to the employed thread I could simply join() to each of these Y threads, but it doesn't. Does anyone know of an elegant way to accomplish this? Thanks.

    Read the article

  • Rails 3 Order By Count on has_many :through

    - by goo
    I have an application where I can list Items and add tags to each Item. The models Items and Tags are associated like this: class Item < ActiveRecord::Base has_many :taggings has_many :tags, :through => :taggings end class Tagging < ActiveRecord::Base belongs_to :item belongs_to :tag end class Tag < ActiveRecord::Base has_many :taggings has_many :items, :through => :taggings end So, this many-to-many relationship allows me to set n tags for each Item, and the same tag can be used several times. I'd like to list all tags ordered by the number of items associated with this tag. More used tags, shows first. Less used, last. How can I do that? Regards.

    Read the article

  • Generating a .CSV with Several Columns - Use a Dictionary?

    - by Qanthelas
    I am writing a script that looks through my inventory, compares it with a master list of all possible inventory items, and tells me what items I am missing. My goal is a .csv file where the first column contains a unique key integer and then the remaining several columns would have data related to that key. For example, a three row snippet of my end-goal .csv file might look like this: 100001,apple,fruit,medium,12,red 100002,carrot,vegetable,medium,10,orange 100005,radish,vegetable,small,10,red The data for this is being drawn from a couple sources. 1st, a query to an API server gives me a list of keys for items that are in inventory. 2nd, I read in a .csv file into a dict that matches keys with item name for all possible keys. A snippet of the first 5 rows of this .csv file might look like this: 100001,apple 100002,carrot 100003,pear 100004,banana 100005,radish Note how any key in my list of inventory will be found in this two column .csv file that gives all keys and their corresponding item name and this list minus my inventory on hand yields what I'm looking for (which is the inventory I need to get). So far I can get a .csv file that contains just the keys and item names for the items that I don't have in inventory. Give a list of inventory on hand like this: 100003,100004 A snippet of my resulting .csv file looks like this: 100001,apple 100002,carrot 100005,radish This means that I have pear and banana in inventory (so they are not in this .csv file.) To get this I have a function to get an item name when given an item id that looks like this: def getNames(id_to_name, ids): return [id_to_name[id] for id in ids] Then a function which gives a list of keys as integers from my inventory server API call that returns a list and I've run this function like this: invlist = ServerApiCallFunction(AppropriateInfo) A third function takes this invlist as its input and returns a dict of keys (the item id) and names for the items I don't have. It also writes the information of this dict to a .csv file. I am using the set1 - set2 method to do this. It looks like this: def InventoryNumbers(inventory): with open(csvfile,'w') as c: c.write('InvName' + ',InvID' + '\n') missinginvnames = [] with open("KeyAndItemNameTwoColumns.csv","rb") as fp: reader = csv.reader(fp, skipinitialspace=True) fp.readline() # skip header invidsandnames = {int(id): str.upper(name) for id, name in reader} invids = set(invidsandnames.keys()) invnames = set(invidsandnames.values()) invonhandset = set(inventory) missinginvidsset = invids - invonhandset missinginvids = list(missinginvidsset) missinginvnames = getNames(invidsandnames, missinginvids) missinginvnameswithids = dict(zip(missinginvnames, missinginvids)) print missinginvnameswithids with open(csvfile,'a') as c: for invname, invid in missinginvnameswithids.iteritems(): c.write(invname + ',' + str(invid) + '\n') return missinginvnameswithids Which I then call like this: InventoryNumbers(invlist) With that explanation, now on to my question here. I want to expand the data in this output .csv file by adding in additional columns. The data for this would be drawn from another .csv file, a snippet of which would look like this: 100001,fruit,medium,12,red 100002,vegetable,medium,10,orange 100003,fruit,medium,14,green 100004,fruit,medium,12,yellow 100005,vegetable,small,10,red Note how this does not contain the item name (so I have to pull that from a different .csv file that just has the two columns of key and item name) but it does use the same keys. I am looking for a way to bring in this extra information so that my final .csv file will not just tell me the keys (which are item ids) and item names for the items I don't have in stock but it will also have columns for type, size, number, and color. One option I've looked at is the defaultdict piece from collections, but I'm not sure if this is the best way to go about what I want to do. If I did use this method I'm not sure exactly how I'd call it to achieve my desired result. If some other method would be easier I'm certainly willing to try that, too. How can I take my dict of keys and corresponding item names for items that I don't have in inventory and add to it this extra information in such a way that I could output it all to a .csv file? EDIT: As I typed this up it occurred to me that I might make things easier on myself by creating a new single .csv file that would have date in the form key,item name,type,size,number,color (basically just copying in the column for item name into the .csv that already has the other information for each key.) This way I would only need to draw from one .csv file rather than from two. Even if I did this, though, how would I go about making my desired .csv file based on only those keys for items not in inventory?

    Read the article

  • ExtJS panel does not render properly unless I open Firebug - WTF?

    - by Huuuze
    I have the following ExtJS Panel embedded in another Panel, which then resides in a TabPanel and the TabPanel is in a FormPanel. With that being said, these start/end date fields are initially displayed in very small cells -- the cells are so small that I see horizontal scroll bars. Now here's the weird part: if I open Firebug, everything pops into place. Does anyone know what's going on? Why isn't it rendering properly in the first place and why does Firebug cause everything to work properly simply by opening Firebug? var dateFields = new Ext.Panel({ id: 'dateFields', labelAlign: 'bottom', border: false, items: [{ layout: 'column', defaults: { columnWidth: 0.5 }, items: [{ layout: 'form', border: false, items: [{ xtype: 'datefield', name: 'start_date', fieldLabel: 'Start Date' }] }, { layout: 'form', border: false, items: [{ xtype: 'datefield', name: 'end_date', fieldLabel: 'End Date' }] }] }] });

    Read the article

  • Qt hide QLayout (switch between two layouts)

    - by Lodhart
    I didn't find solution for my problem with two QLayouts. I need app with QHBoxLayout with possible expandind when I will add new widgets, push buttons, .... So what I have: One QDialog and two layouts. Now I know that I can't hide the layout. So I tray just : layout()->removeItem(firstlayout); layout()->addLayout(secondLayout); But when I did this, I saw all items in first layout on possition [0,0]. So next step I try: for (all items in first layout) if (widget) widget->hide(); But this is working only with QWidget and I have many different items in layouts. Simply way is use the widget, because there is possibole to use hide/show, but I need auto expanding window when I add new items.

    Read the article

  • Mysql SELECT with an OR across 2 columns

    - by Haroldo
    I'm creating a 'similar items' link table. i have a 2 column table. both columns contains product ids. The table is showing that these items are similar. However ids in the left column are more valuable. Say i want to select similar items to product '125b'. i only want 3 similar items to 125b. If there are any instances of 125b in col1 I would prefer these to finding 125b in col2. so i need a select statement along the lines of SELECT * FROM similar_items WHERE col_1={$id} OR col_2={$id} ORDER BY column(?) LIMIT 3 i do not want to do 2 separate queries ( ie query 2 if count(query1) <3 )

    Read the article

  • Set the right two characters (if there are any) to capitals?

    - by Hyflex
    Below is my data: Data Here 94/452O Data more 94/4522i Data bla 94/111 Data bla 94/459es Data bla 94/444 items is automatically generated by some previous code but it could come out like: items = ["Data Here 94/452O", "Data more 94/4522i", "Data bla 94/111", "Data bla 94/459es", "Data bla 94/444"] Now currently I'm appending the following: "\n".join(items).replace("4ke", "9") with a few other .replaces however I want it to replace/change the characters on the end of the numbers with a capital letter instead of lowercase... Output: Data Here 94/452O Data more 94/4522I Data bla 94/111 Data bla 94/459ES Data bla 94/444

    Read the article

  • Permutations with extra restrictions

    - by Full Decent
    I have a set of items, for example: {1,1,1,2,2,3,3,3}, and a restricting set of sets, for example {{3},{1,2},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{2,3},{2,3}. I am looking for permutations of items, but the first element must be 3, and the second must be 1 or 2, etc. One such permutation that fits is: {3,1,1,1,2,2,3} Is there an algorithm to count all permutations for this problem in general? Is there a name for this type of problem? For illustration, I know how to solve this problem for certain types of "restricting sets". Set of items: {1,1,2,2,3}, Restrictions {{1,2},{1,2,3},{1,2,3},{1,2},{1,2}}. This is equal to 2!/(2-1)!/1! * 4!/2!/2!. Effectively permuting the 3 first, since it is the most restrictive and then permuting the remaining items where there is room.

    Read the article

  • How to map one class against multiple tables with SQLAlchemy?

    - by tote
    Lets say that I have a database structure with three tables that look like this: items - item_id - item_handle attributes - attribute_id - attribute_name item_attributes - item_attribute_id - item_id - attribute_id - attribute_value I would like to be able to do this in SQLAlchemy: item = Item('item1') item.foo = 'bar' session.add(item) session.commit() item1 = session.query(Item).filter_by(handle='item1').one() print item1.foo # => 'bar' I'm new to SQLAlchemy and I found this in the documentation (http://www.sqlalchemy.org/docs/05/mappers.html#mapping-a-class-against-multiple-tables): j = join(items, item_attributes, items.c.item_id == item_attributes.c.item_id). \ join(attributes, item_attributes.c.attribute_id == attributes.c.attribute_id) mapper(Item, j, properties={ 'item_id': [items.c.item_id, item_attributes.c.item_id], 'attribute_id': [item_attributes.c.attribute_id, attributes.c.attribute_id], }) It only adds item_id and attribute_id to Item and its not possible to add attributes to Item object. Is what I'm trying to achieve possible with SQLAlchemy? Is there a better way to structure the database to get the same behaviour of "dynamic columns"?

    Read the article

  • Convert JSON into array dataType

    - by Myhome Stories
    I have the following JSON string var json = {"result":[{"address":" Ardenham Court, Oxford Road ,AYLESBURY, BUCKINGHAMSHIRE ,UNITED KINGDOM","picture":"1.jpg","uniqueid":"8b54275a60088547d473d462763b4738","story":"I love my home. I feel safe, I am comfortable and I am loved. A home can't be a home without our parents and our loved ones. But sad to say, some are experiencing that eventhough their loved ones are in their houses, they are not loving each other. There is a big war. You can't call it a home."}]} I want to get address ,picture,story separately for accomplish this. I tried recent answers in stackoverflow, but I was not able to achieve it. Below is what I have tried, $.each(json.result.address, function (index, value) { // Get the items var items = this.address; // Here 'this' points to a 'group' in 'groups' // Iterate through items. $.each(items, function () { console.log(this.text); // Here 'this' points to an 'item' in 'items' }); });

    Read the article

  • numberOfSectionsInTable isn't called when [arr count] is returned

    - by user315471
    When I try returning the count of my newsItems array it breaks my application. I used NSLog to find out what the value of the newsItems count was when I returned 1. Here is from NSLog 2010-04-13 07:48:40.656 RSS Feed[453:207] Values of num items 31 2010-04-13 07:48:40.656 RSS Feed[453:207] Number of items 31 Does anyone know why returning [newsItems count] would cause my application to break? - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { NSLog(@"Values of num items %d",[newsItems count]); NSInteger *length = (NSInteger *)[newsItems count]; NSLog(@"Number of items %d",length); return 1; //return [newsItems count]; //This keeps breaking it for some reason }

    Read the article

  • Apache mod_rewrite : How to REWRITE (or whatever) child directories to parent?

    - by ????
    Actually i am trying to make a PHP MVC like application. A basic one. The current milestone i am reaching already includes: Basic RESTful Routing Means, if i type: www.example.com/items/book/8888 .. it properly just stays there as it is and i can already slice out the URL by slashes / and loads the responsible Controllers .... etc from the top single index.php file. I mean, so it is OK for the backend PHP. But the only problem is, it still CAN NOT process the REWRITES properly. For example, the CSS & JS are BROKEN as if i VIEW PAGE SOURCE of the page www.example.com/items/book/8888, the asset files are being called as: www.example.com/items/book/8888/css/main.css www.example.com/items/book/8888/js/jquery.js .. which really are PROBLEMS because in the code is like: <link type="text/css" rel="stylesheet" media="all" href="css/main.css"> <script type="text/javascript" src="js/jquery.js"></script> So the question is: How can i use Apache REWRITE (or whatever approach) to make sure every ASSET FILES to be correctly being called from the DOCROOT. For example, if i am in the URL: www.example.com/items/book/8888 My ASSET FILES should still be called as: www.example.com/css/main.css www.example.com/js/jquery.js Or is there any other methods i need to follow? Please kindly help suggest. Thank you.

    Read the article

  • C# start a static thread

    - by user595605
    I have a Queue of items I want to process in a thread, and any instance of a class can add items to the Queue to be processed. My idea for doing this is to have a static Thread in the class that processes the items, the only problem is that I don't know where to start this thread, since I can't start it in its initialization. Is there a way I can start a static thread? Or should I be changing the architecture completely?

    Read the article

  • Getting screen height before first display?

    - by Mark
    Hi, I have a ListView. I populate it with 8 items, that's all that fits vertically on the G1. Some of my users are saying the Droid has a taller screen height, and so I can probably add one or two more items to the ListView to take up the additional space provided. How could I measure the available height the screen offers at startup, before the UI is displayed? If I see the height can fit more than 8 items, I'd like to add one or two more rows, Thanks

    Read the article

  • How to return result set based on other rows

    - by understack
    I've 2 tables - packages and items. Items table contains all items belonging to the packages along with location information. Like this: Packages table id, name, type(enum{general,special}) 1, name1, general 2, name2, special Items table id, package_id, location 1, 1, America 2, 1, Africa 3, 1, Europe 4, 2, Europe Question: I want to find all 'special' packages belonging to a location and if no special package is found then it should return 'general' packages belonging to same location. So, for 'Europe' : package 2 should be returned since it is special package (Though package 1 also belongs to Europe but not required since its a general package) for 'America' : package 1 should be returned since there are no special packages

    Read the article

  • Second query to SQLite (on iPhone) errors.

    - by Luke
    Hi all, On the iPhone, I am developing a class for a cart that connects directly to a database. To view the cart, all items can be pulled from the database, however, it seems that removing them doesn't work. It is surprising to me because the error occurs during connection to the database, except not the second time I connect even after the DB has been closed. #import "CartDB.h" #import "CartItem.h" @implementation CartDB @synthesize database, databasePath; - (NSMutableArray *) getAllItems { NSMutableArray *items = [[NSMutableArray alloc] init]; if([self openDatabase]) { const char *sqlStatement = "SELECT * FROM items;"; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(cartDatabase, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { while(sqlite3_step(compiledStatement) == SQLITE_ROW) { int rowId = sqlite3_column_int(compiledStatement, 0); int productId = sqlite3_column_int(compiledStatement, 1); NSString *features = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; int quantity = sqlite3_column_int(compiledStatement, 3); CartItem *cartItem = [[CartItem alloc] initWithRowId:rowId productId:productId features:features quantity:quantity]; [items addObject:cartItem]; [cartItem release]; } } sqlite3_finalize(compiledStatement); } [self closeDatabase]; return items; } - (BOOL) removeCartItem:(CartItem *)item { sqlite3_stmt *deleteStatement; [self openDatabase]; const char *sql = "DELETE FROM items WHERE id = ?"; if(sqlite3_prepare_v2(cartDatabase, sql, -1, &deleteStatement, NULL) != SQLITE_OK) { return NO; } sqlite3_bind_int(deleteStatement, 1, item.rowId); if(SQLITE_DONE != sqlite3_step(deleteStatement)) { sqlite3_reset(deleteStatement); [self closeDatabase]; return NO; } else { sqlite3_reset(deleteStatement); [self closeDatabase]; return YES; } } - (BOOL) openDatabase { if(sqlite3_open([databasePath UTF8String], &cartDatabase) == SQLITE_OK) { return YES; } else { return NO; } } - (void) closeDatabase { sqlite3_close(cartDatabase); } The error occurs on the line where the connection is opened in openDatabase. Any ideas? Need to flush something? Something gets autoreleased? I really can't figure it out. --Edit-- The error that I receive is GDB: Program received signal "EXC_BAD_ACCESS". --Edit-- I ended up just connecting in the init and closing in the free methods, which might not be the proper way, but that's another question altogether so it's effectively persistent instead of connecting multiple times. Still would be nice to know what was up with this for future reference.

    Read the article

  • Create ordering in a MySQL table without using a number (because then it's hard to put something in

    - by user347256
    I have a long list of items (say, a few million items) in a mysql table, let's call it mytable and it has the field mytable.itemid. The items are given an order, and can be re=ordered by the user by drag and drop. If I add a field called mytable.order and just put numbers in them, it creates problems: what if I want to move an item between 2 other items? Then all the order fields have to be updated? That seems like a nightmare. Is there a (scalable) way to add order to a table that is different from just giving every item a number, order by that, and do loads of SQL queries everytime the order is changed?

    Read the article

< Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >