Search Results

Search found 9542 results on 382 pages for 'row'.

Page 16/382 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Consolidated queue for video on demand?

    - by Herb Caudill
    It's great having lots of video on demand options, but actually choosing something to watch is turning into a mess - I have to jump from one website or application to another. I'd like to have a single queue where I can add and prioritize movies and TV I want to watch from any source: iTunes purchases, iTunes rentals, Netflix on demand, Amazon video on demand, Hulu, etc. I'd like the consolidated queue to be accessible from Front Row on my Mac Mini. Does such a thing exist?

    Read the article

  • How to delete row in TTTableViewController (Three20)

    - by Dmitry
    Hi, The Three20 is great library. It's making the work with tables very easy. But one gap that I noticed - is deletion of rows, with animation. I spent many hours trying to do this, and this is what I'm doing: // get current index patch UITableView* table = [super tableView]; NSIndexPath *indexPath = [table indexPathForSelectedRow]; //delete row in data source TTListDataSource * source = (TTListDataSource *)self.dataSource; [source.items removeObjectAtIndex:indexPath.row]; // delete row from the table, with animation [table deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; After this code runs the error appears: [NSCFArray objectAtIndex:]: index (0) beyond bounds (0) I'm using the class inherited from the TTTableViewController. And I doesn't implement the DataSourceDelegate or TableViewDelegate because I'm using the Three20 as much as possible. So, this is how I create datasource: for(NSDictionary *album in (NSArray *)albums){ TTTableRightImageItem *item = [TTTableRightImageItem itemWithText:@"name" imageURL:@"image url" defaultImage:nil imageStyle:TTSTYLE(rounded) URL:@"url of selector where I actually catch the tap on a row"]; [tableItems addObject:item]; } self.dataSource = [TTListDataSource dataSourceWithItems:tableItems]; I read this article (article) but it doesn't help :( So, I know that this is very simple for gurus from this site. Can you just give me advanced sample of how to do this Thanks

    Read the article

  • GridView row remove and animation - Android

    - by Pria
    I have a GridView in which each row has a custom view. The grid view adapter has an array that keeps the custom view. At click of a button, I want to remove a specific row from the Grid and while doing so I want animation on it. I have an AnimationListener. When I remove the upper most row from the array and setAdapter in onAnimationEnd(). It works perfectly fine. But, when I remove any other row, it gives a NullPointerException in the main thread. The exception thread is as follows: ERROR/AndroidRuntime(11503): java.lang.NullPointerException at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1227) at android.widget.AbsListView.dispatchDraw(AbsListView.java:1319) at android.view.View.draw(View.java:5944) at android.widget.AbsListView.draw(AbsListView.java:2121) at android.view.ViewGroup.drawChild(ViewGroup.java:1486) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228) at android.view.View.draw(View.java:5841) at android.widget.FrameLayout.draw(FrameLayout.java:352) at android.view.ViewGroup.drawChild(ViewGroup.java:1486) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228) at android.view.View.draw(View.java:5841) at android.widget.FrameLayout.draw(FrameLayout.java:352) at android.view.ViewGroup.drawChild(ViewGroup.java:1486) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228) at android.view.View.draw(View.java:5841) at android.widget.FrameLayout.draw(FrameLayout.java:352) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1847) at android.view.ViewRoot.draw(ViewRoot.java:1217) at android.view.ViewRoot.performTraversals(ViewRoot.java:1030) at android.view.ViewRoot.handleMessage(ViewRoot.java:1482) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3948) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) at dalvik.system.NativeStart.main(Native Method) Please help!!!

    Read the article

  • Jqgrid: navigation based on the selected row

    - by bsreekanth
    Hello, I was trying to enable navigation based on a selected row. So, the user select a row from jQgrid, and when press the show (is there a show button for the grid, I saw edit, add etc), it needs to go to a new page based on the url (part of the row). $(document).ready(function () { function getLink() { // var rowid = $("#customer_list").jqGrid('getGridParam', 'selrow'); var rowid = $("#customer_list").getGridParam('selrow'); var MyCellData = $("#customer_list").jqGrid('getCell', rowid, 'dataUrl'); return MyCellData; } $("#customer_list").jqGrid({ url:'mytestList', editurl:'jq_edit_test', datatype: "json", colNames:['Call Id','Title','dataUrl'], colModel:[ {name:'callId', width:80, search:false }, {name:'title', width:200, sortable:false }, {name:'dataUrl',hidden:true} ], rowNum:10, sortname:'lastUpdated', sortorder: 'desc', pager:'#customer_list_pager', viewrecords: true, gridview: true }).navGrid('#customer_list_pager', {add:true,edit:true,del:false,search:true,refresh:true}, {closeAfterEdit:true, afterSubmit:afterSubmitEvent }, // edit options {addCaption:'Create New something', afterSubmit:afterSubmitEvent, savekey:[true,13]}, // add options {afterSubmit:afterSubmitEvent} // delete options ); $("#customer_list").jqGrid('filterToolbar'); }); so, the url is passed for each row as dataUrl. I'm trying to read it and set to the button. Whn debug through firebug, the rowid was 223 (there were only 12 rows in the grid), and the cell value is empty. Currently the button is kept outside the grid, but it may better to be it part of the vavGrid thanks.

    Read the article

  • Creating a drop-down row in displaytag

    - by bphilipnyc
    I am currently using displaytag for tabular data, but would like to create a "kayak.com-like" interface where when a user clicks a row, the user is shown more details about the particular row without a page refresh. I tried using a decorator to return javascript that would do this. The javascript is executed, but it is only reflected in the column where it was rendered. I am looking to create a new row with the data. e.g.: public class CustomDecorator extends TableDecorator { public String getDetailsRow() { MyObject object = (MyObject)this.getCurrentRowObject(); return "<a onClick=\"myjsfunction(object.getId()); return true\">Details</a>"; } } ...and in the JSP I would have a detailsRow property nested between the display:table tags: <display:column property="detailsRow" sortable="false" /> Any tips on how to create a new row? The solution may be in the way that the javascript is written - I'm not an expert with Javascript, so any tips would be appreciated. Is there a better way to do this with displaytag? I don't know of any explicit integration that displaytag has with javascript (like an "onclick" parameter) either. This is my first question on stackoverflow, btw - so please let me know whether you need more detail.

    Read the article

  • XAML ContextMenu gets bound to wrong row in a DataGrid

    - by Simon_Weaver
    I have a XAML based ContextMenu bound to the rows in a datagrid. It works just fine - until the grid is scrolled! This is the context menu for one of the controls in the visual tree or a DataGrid row. <data:DataGridTemplateColumn Header="Customer Details" Width="*"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <Grid Background="Transparent"> <!-- allows click in entire cell --> <controlsInputToolkit:ContextMenuService.ContextMenu> <controlsInputToolkit:ContextMenu> <controlsInputToolkit:MenuItem Header="{Binding CompletedOrderId,StringFormat='Create Reminder for order #\{0\}'}" CommandParameter="{Binding}"> <controlsInputToolkit:MenuItem.Command> <command:CreateReminderCommand/> </controlsInputToolkit:MenuItem.Command> <controlsInputToolkit:MenuItem.Icon> <Viewbox> <Image Width="19" Height="18" Source="../images/reminders.png" VerticalAlignment="Center"/> </Viewbox> </controlsInputToolkit:MenuItem.Icon> </controlsInputToolkit:MenuItem> <controlsInputToolkit:ContextMenu> <controlsInputToolkit:ContextMenuService.ContextMenu> ...... The ICommand is CreateReminderCommand and the CommandParameter is bound to the data item for the row itself. This works just fine - I can right click on a row and it will show me the correct text in the menu item 'Create Reminder for order 12345'. Then I scroll the datagrid down a page. If I keep right clicking on items then suddenly I'll see the wrong order number for a row. I think what must be happening is this : The DataGrid is reusing instances of MenuItem that it has previously created. How can I force a refresh of the ContextMenu when it is displayed for an item that changes? There's no 'Update method on the ContextMenu or ContextMenuService.

    Read the article

  • Inserting new <TD> elements into a table row.

    - by Hunter S. Smythe
    I have created a small application written in XHTML, JavaScript/JQuery and PHP. The PHP reads and writes to a small SQLite database. How would i go about inserting cells into a pre-scripted table. The cells would need to be configured using some information from my database. For example, below are two cells with their data retrieved from my database: Cell One Starts: 120px; Finishes: 180px; Background: Blue; Cell Two Starts: 240px; Finishes: 300px; Background: Green; On my table row, it is 500px in width. How would I insert the cells above into the row. In this example, the first cell would start 120px into the row and have a width of 180px. The second cell would start 240px into the row and have a width of 300px. I just cant seem to work out a way of doing this, any ideas would be very helpful. Thank you for any input, all is appreciated. Hunter.

    Read the article

  • Toggle row visibility one at a time

    - by kuswantin
    I have a couple of tables with similar structures like this: <table> <tbody> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> <tr>content</tr> ..etc --- The fake button is added here <div class="addrow">Add another</div> </tbody> </table> Since this is a long list, I have a need to toggle the rows one at a time. I just need to show the first row, of course, the rest should be toggled. The action is when I click a dynamic fake button, it will show row no. 2, and clicking again will show another next row. This is what I have done so far: $("table#field_fruit_values tr.draggable").not(':first').hide(); $("table#field_vegetables_values tr.draggable").not(':first').hide(); $("body.form table.content-multiple-table tbody").append('<div class="addrow">Add</div>'); $(".addrow").click(function() { var hiddenRow = $(this).prev('tr.draggable'); $(this).prev(hiddenRow + 1).show(); //if (hiddenRow + ':last').length) { // <= silly logic // $(this).hide(); //} }); The button only works for one row. I must have done something wrong :) When the final is reached, I also want the button to disappear. Sorry if this question sound silly. Any help would be very much appreciated. Thanks.

    Read the article

  • Maintaining Selected Row of the DataGridView Control after refreshing Data

    - by user575219
    I am trying to Maintain Selected Row of the DataGridView Control after refreshing Data. This is my code public partial class frmPlant : Form { string gSelectedPlant; private void frmPlant_Load(object sender, EventArgs e) { dataGridView1.AutoGenerateColumns = true; dataGridView1.DataSource = bindingSource1; FillData(); dataGridView1.DataMember = "Table"; } private void FillData() { ds = _DbConnection.returnDataSet(_SQlQueries.SQL_PlantSelect); bindingSource1.DataSource = ds.Tables[0]; } public DataSet returnDataSet(string txtQuery) { conn.Open(); sqlCommand = conn.CreateCommand(); DB = new SQLiteDataAdapter(txtQuery, conn); DS.Reset(); DB.Fill(DS); conn.Close(); return (DS); } private void dataGridView1_Selectionchanged(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { gSelectedPlant = dataGridView1.SelectedRows[0].Cells["PlantId"].Value.ToString(); } } private void dataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { int selectedIndex; if (!string.IsNullOrEmpty(gSelectedPlant) && e.ListChangedType == ListChangedType.Reset) { if (ds.Tables.Count > 0) { selectedIndex = bindingSource1.Find("PlantId", gSelectedPlant); if (selectedIndex <= 0) selectedIndex = 0; dataGridView1.Rows[selectedIndex].Selected = true; } else { gSelectedPlant = string.Empty; } } } } It is still not able to maintain the rowindex of the selected row. It scrolls to row1. Here's the blog I used http://www.makhaly.net/Blog/9 Suppose, I select a row on Form1(where all this code is) and go on the next form, which shows me detailed info abt the particular Plant . If I come back to this first form again,by pressing the back button, the row is reset to 1. gSelectedPlant takes a value 1 and selectedindex = 0. This makes sense but I am not yet able to figure out how to maintain the value of gSelectedPlant. Yes it takes a null intitally but on databindingcomplete it becomes 1.

    Read the article

  • Zend: Fetching row from session db table after generating session id

    - by Nux
    Hi, I'm trying to update the session table used by Zend_Session_SaveHandler_DbTable directly after authenticating the user and writing the session to the DB. But I can neither update nor fetch the newly inserted row, even though the session id I use to check (Zend_Session::getId()) is valid and the row is indeed inserted into the table. Upon fetching all session ids (on the same request) the one I newly inserted is missing from the results. It does appear in the results if I fetch it with something else. I've checked whether it is a problem with transactions and that does not seem to be the problem - there is no active transaction when I'm fetching the results. I've also tried fetching a few seconds after writing using sleep(), which doesn't help. $auth->getStorage()->write($ident); //sleep(1) $update = $this->db->update('session', array('uid' => $ident->user_id), 'id='.$this->db->quote(Zend_Session::getId())); $qload = 'SELECT id FROM session'; $load = $this->db->fetchAll($qload); echo $qload; print_r($load); $update fails. $load doesn't contain the row that was written with $auth-getStorage()-write($identity). $qload does contain the correct query - copying it to somewhere else leads to the expected result, that is the inserted row is included in the results. Database used is MySQL - InnoDB. If someone knows how to directly fix this (i.e. on the same request, not doing something like updating after redirecting to another page) without modifying Zend_Session_SaveHandler_DbTable: Thank you very much!

    Read the article

  • security deleting a mysql row with jQuery $.post

    - by FFish
    I want to delete a row in my database and found an example on how to do this with jQuery's $.post() Now I am wondering about security though.. Can someone send a POST request to my delete-row.php script from another website? JS function deleterow(id) { // alert(typeof(id)); // number if (confirm('Are you sure want to delete?')) { $.post('delete-row.php', {album_id:+id, ajax:'true'}, function() { $("#row_"+id).fadeOut("slow"); }); } } PHP: delete-row.php <?php require_once("../db.php"); mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD) or die("could not connect to database " . mysql_error()); mysql_select_db(DB_NAME) or die("could not select database " . mysql_error()); if (isset($_POST['album_id'])) { $query = "DELETE FROM albums WHERE album_id = " . $_POST['album_id']; $result = mysql_query($query); if (!$result) die('Invalid query: ' . mysql_error()); echo "album deleted!"; } ?>

    Read the article

  • help in selecting a row in a tableview and pushing that row into anotherview? sturgling on this sinc

    - by Madhu
    Hi, I have a list of about 5 items in a tableview which I bought them from a database and now when i am trying to push each of them into different views in DidSelectRow() what I am seeing is it is showing me all the views in all the categories.... here is the code I have written.... Here is the code written in cell for row at indexpath: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } BeautyQuotes *bQuote = (BeautyQuotes*)[mBeautyQ objectAtIndex:indexPath.row]; cell.textLabel.text = bQuote.qBeauty; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator] ; return cell; and in didselectrow() i have written this code: id count1 = [mBeautyQ count]; while (count1--) { object = [mBeautyQ objectAtIndex:count1]; } [mBeautyQ release]; if([[object objectAtIndex:indexPath.row] isEqual : @"Beauty Quotes"]){ [tableView deselectRowAtIndexPath:indexPath animated:NO]; BeautysubViewController *subBeauty = [[BeautysubViewController alloc] initWithNibName:@"BeautysubViewController" bundle:nil]; //subBeauty.selected =[regions objectAtIndex:indexPath.row];(this is not working) [subBeauty setTitle:@"Beauty Quotes"]; NSLog(@"it is about push beauty subview controller"); [self.navigationController pushViewController:subBeauty animated:YES]; [subBeauty release]; } in this way i am pusing all the rows in to different views....but when I am pushing this into beautyquotes it is showing me all other views along with this.... struggling on this a lot please help me in dealing with this....

    Read the article

  • row number over text column sort

    - by Marty Trenouth
    I'm having problems with dynamic sorting using ROW Number in SQL Server. I have it working but it's throwing errors on non numeric fields. What do I need to change to get sorts with Alpha Working??? ID Description 5 Test 6 Desert 3 A evil Ive got a Sql Prodcedure CREATE PROCEDURE [CRUDS].[MyTable_Search] -- Add the parameters for the stored procedure here -- Full Parameter List @ID int = NULL, @Description nvarchar(256) = NULL, @StartIndex int = 0, @Count int = null, @Order varchar(128) = 'ID asc' AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- Insert statements for procedure here Select * from ( Select ROW_NUMBER() OVER (Order By case when @Order = 'ID asc' then [TableName].ID when @Order = 'Description asc' then [TableName].Description end asc, case when @Order = 'ID desc' then [TableName].ID when @Order = 'Description desc' then [TableName].Description end desc ) as row, [TableName].* from [TableName] where (@ID IS NULL OR [TableName].ID = @ID) AND (@Description IS NULL OR [TableName].Description = @Description) ) as a where row > @StartIndex and (@Count is null or row <= @StartIndex + @Count) order by case when @Order = 'ID asc' then a.ID when @Order = 'Description asc' then a.Description end asc, case when @Order = 'ID desc' then a.ID when @Order = 'Description desc' then a.Description end desc END

    Read the article

  • dynamically insert new rows in the table (JavaScript) ?

    - by Karandeep Singh
    <script type="text/javascript" language="javascript"> function addNewRow() { var table = document.getElementById("table1"); var tr = table.insertRow(); var td = tr.insertCell(); td.innerHTML= "a"; td = tr.insertCell(); td.innerHTML= "b"; td = tr.insertCell(); td.innerHTML= "c"; td = tr.insertCell(); td.innerHTML= "d"; td = tr.insertCell(); td.innerHTML= "e"; } </script> <body> <table id="table1" border="1" cellpadding="0" cellspacing="0" width="100%"> <tr id="row1"> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> </tr> </table> <input type="button" onClick="addNewRow()" value="Add New"/> </body> This example is for dynamically insert new row and cells in the table. But its behavior is different in all browsers. Internet Explorer = It add row in the last and new added cells are starts from first. Chrome/Safari = It add new row in the first and new added cells are starts from end. Mozilla Firefox = It is not working. Sir, I want new added row in the last and new added cells starts from first like(Interner Explorer) in all browsers. If you have any solution for same behavior please tell me. Thanks,

    Read the article

  • Handling row selection from a simple grid using jquery and asp.net mvc

    - by Jonn
    Using a simple table and jquery, how would you manually handle selection using jquery? So far, I've managed to add a gridrowselected class on the tr when the click event is called so that I'll know which row is currently selected. But I don't know how to pass the selected data back to the controller (or at least an index I placed on the row). I tried something like this $(function() { $('#ProjectList .gridrow').click(function() { // Get row's index var projectId = $(this).find('input[name$=ProjectId]').val(); // Remove the input if it already exists var parentForm = $(this).parents('form'); parentForm.remove('input[name="selectedRows"][value="' + projectId + '"]'); // If it is selected, create the form. If it's not selected then the input just gets removed (the user must have clicked on it and deselected the row) if ($(this).hasClass('gridrow-selected') === true) { parentForm.append($('<input>', { type: "hidden", name: "selectedRows", value: projectId })); } }); }); which I'm expecting to create a hidden input so that when I post, selectedRows gets passed onto the controller. But all it does is create the input, but the data still doesn't get passed to the controller.

    Read the article

  • Jquery push data to the good row.

    - by marharépa
    Hi! This is my big problem. This script put the information to a table. function handleAccountFeed(result) { var entries = result.feed.getEntries(); var outputTable = ['<table><tr>', '<th>Account Name</th>', '<th>Profile Name</th>', '<th>Profile ID</th>', '<th>Table Id</th></tr>']; for (var i = 0, entry; entry = entries[i]; ++i) { var row = [ entry.getPropertyValue('ga:AccountName'), entry.getTitle().getText(), entry.getPropertyValue('ga:ProfileId'), entry.getTableId().getValue() ].join('</td><td>'); outputTable.push('<tr><td>', row, '</td></tr>'); } outputTable.push('</table>'); document.getElementById('outputDiv').innerHTML = outputTable.join(''); } I've got an own SMARTY template, which makes a table: <table id="stuffs"> <tbody> {section name=i loop=$ownsites} <tr><td>{$ownsites[i].id}</td><td>{$ownsites[i].domain}</td><td>PLACE</td></tr> {/section} <tbody> </table> I'd like to put the TableId (getTableId().getValue()) to that row's PLACE where {$ownsites[i].domain} is equal to the jquery row's Title (getTitle().getText()) How can i do this within this jQuery script?

    Read the article

  • saving mySql row checkpoint in table ?

    - by Keet
    hello, I am having a wee problem, and I am sure there is a more convenient/simpler way to achieve the solution, but all searches are throw in up a blanks at the moment ! I have a mysql db that is regularly updated by php page [ via a cron job ] this adds or deletes entries as appropriate. My issue is that I also need to check if any details [ie the phone number or similar] for the entry have changed, but doing this at every call is not possible [ not only does is seem to me to be overkill, but I am restricted by a 3rd party api call limit] Plus this is not critical info. So I was thinking it might be best to just check one entry per page call, and iterate through the rows/entires with each successive page call. What would be the best way of doing this, ie keeping track of which entry/row in the table that the should be checked next? I have 2 ideas of how to implement this: 1 ) The id of current row could be save to a file on the server [ surely not the best way] 2) an extra boolean field [check] is add to the table, set to True on the first entry and false to all other. Then on each page call it; finds 'where check = TRUE' runs the update check on this row, 'set check = FALSE' 'set [the next row] check = TRUE' Si this the best way to do this, or does anyone have any better sugestion ? thanks in advance ! .k PS sorry about the title

    Read the article

  • Why is my simple recusive method for this game always off by 1?

    - by FrankTheTank
    I'm attempting to create a text-based version of this game: http://www.cse.nd.edu/java/SameGame.html Here is the code I have so far: #include <iostream> #include <vector> #include <ctime> class Clickomania { public: Clickomania(); std::vector<std::vector<int> > board; int move(int, int); bool isSolved(); void print(); void pushDown(); bool isValid(); }; Clickomania::Clickomania() : board(12, std::vector<int>(8,0)) { srand((unsigned)time(0)); for(int i = 0; i < 12; i++) { for(int j = 0; j < 8; j++) { int color = (rand() % 3) + 1; board[i][j] = color; } } } void Clickomania::pushDown() { for(int i = 0; i < 8; i++) { for(int j = 0; j < 12; j++) { if (board[j][i] == 0) { for(int k = j; k > 0; k--) { board[k][i] = board[k-1][i]; } board[0][i] = 0; } } } } int Clickomania::move(int row, int col) { bool match = false; int totalMatches = 0; if (row > 12 || row < 0 || col > 8 || col < 0) { return 0; } int currentColor = board[row][col]; board[row][col] = 0; if ((row + 1) < 12) { if (board[row+1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row+1, col); } } if ((row - 1) >= 0) { if (board[row-1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row-1, col); } } if ((col + 1) < 8) { if (board[row][col+1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col+1); } } if ((col - 1) >= 0) { if (board[row][col-1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col-1); } } return totalMatches; } void Clickomania::print() { for(int i = 0; i < 12; i++) { for(int j = 0; j < 8; j++) { std::cout << board[i][j]; } std::cout << "\n"; } } int main() { Clickomania game; game.print(); int row; int col; std::cout << "Enter row: "; std::cin >> row; std::cout << "Enter col: "; std::cin >> col; int numDestroyed = game.move(row,col); game.print(); std::cout << "Destroyed: " << numDestroyed << "\n"; } The method that is giving me trouble is my "move" method. This method, given a pair of coordinates, should delete all the squares at that coordinate with the same number and likewise with all the squares with the same number connected to it. If you play the link I gave above you'll see how the deletion works on a click. int Clickomania::move(int row, int col) { bool match = false; int totalMatches = 0; if (row > 12 || row < 0 || col > 8 || col < 0) { return 0; } int currentColor = board[row][col]; board[row][col] = 0; if ((row + 1) < 12) { if (board[row+1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row+1, col); } } if ((row - 1) >= 0) { if (board[row-1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row-1, col); } } if ((col + 1) < 8) { if (board[row][col+1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col+1); } } if ((col - 1) >= 0) { if (board[row][col-1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col-1); } } return totalMatches; } My move() method above works fine, as in, it will delete the appropriate "blocks" and replace them with zeros. However, the number of destroyed (value returned) is always one off (too small). I believe this is because the first call of move() isn't being counted but I don't know how to differentiate between the first call or subsequent calls in that recursive method. How can I modify my move() method so it returns the correct number of destroyed blocks?

    Read the article

  • Why is my simple recusive method's final return value always off by 1?

    - by FrankTheTank
    I'm attempting to create a text-based version of this game: http://www.cse.nd.edu/java/SameGame.html Here is the code I have so far: #include <iostream> #include <vector> #include <ctime> class Clickomania { public: Clickomania(); std::vector<std::vector<int> > board; int move(int, int); bool isSolved(); void print(); void pushDown(); bool isValid(); }; Clickomania::Clickomania() : board(12, std::vector<int>(8,0)) { srand((unsigned)time(0)); for(int i = 0; i < 12; i++) { for(int j = 0; j < 8; j++) { int color = (rand() % 3) + 1; board[i][j] = color; } } } void Clickomania::pushDown() { for(int i = 0; i < 8; i++) { for(int j = 0; j < 12; j++) { if (board[j][i] == 0) { for(int k = j; k > 0; k--) { board[k][i] = board[k-1][i]; } board[0][i] = 0; } } } } int Clickomania::move(int row, int col) { bool match = false; int totalMatches = 0; if (row > 12 || row < 0 || col > 8 || col < 0) { return 0; } int currentColor = board[row][col]; board[row][col] = 0; if ((row + 1) < 12) { if (board[row+1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row+1, col); } } if ((row - 1) >= 0) { if (board[row-1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row-1, col); } } if ((col + 1) < 8) { if (board[row][col+1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col+1); } } if ((col - 1) >= 0) { if (board[row][col-1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col-1); } } return totalMatches; } void Clickomania::print() { for(int i = 0; i < 12; i++) { for(int j = 0; j < 8; j++) { std::cout << board[i][j]; } std::cout << "\n"; } } int main() { Clickomania game; game.print(); int row; int col; std::cout << "Enter row: "; std::cin >> row; std::cout << "Enter col: "; std::cin >> col; int numDestroyed = game.move(row,col); game.print(); std::cout << "Destroyed: " << numDestroyed << "\n"; } The method that is giving me trouble is my "move" method. This method, given a pair of coordinates, should delete all the squares at that coordinate with the same number and likewise with all the squares with the same number connected to it. If you play the link I gave above you'll see how the deletion works on a click. int Clickomania::move(int row, int col) { bool match = false; int totalMatches = 0; if (row > 12 || row < 0 || col > 8 || col < 0) { return 0; } int currentColor = board[row][col]; board[row][col] = 0; if ((row + 1) < 12) { if (board[row+1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row+1, col); } } if ((row - 1) >= 0) { if (board[row-1][col] == currentColor) { match = true; totalMatches++; totalMatches += move(row-1, col); } } if ((col + 1) < 8) { if (board[row][col+1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col+1); } } if ((col - 1) >= 0) { if (board[row][col-1] == currentColor) { match = true; totalMatches++; totalMatches += move(row, col-1); } } return totalMatches; } My move() method above works fine, as in, it will delete the appropriate "blocks" and replace them with zeros. However, the number of destroyed (value returned) is always one off (too small). I believe this is because the first call of move() isn't being counted but I don't know how to differentiate between the first call or subsequent calls in that recursive method. How can I modify my move() method so it returns the correct number of destroyed blocks?

    Read the article

  • How to turn off Excel "Header Row" without losing data in it?

    - by Ken
    I've been sent an Excel spreadsheet with a weird first row. Some of the cells say "Column1", "Column2", etc., but I can't delete their contents. If I select the cell and hit backspace, it goes blank, but when I press return, it goes right back to saying "Column1". I found another answer here that suggested this could be caused by "Cell validation", but the validation window says "Any value", and also "show alert" (and I'm not seeing an alert), so I don't think that's it. The first row is white text on a blue background, if that means anything. The spreadsheet was sent to me in XLSX format, but I tried resaving as XLS and opening that, and it seems to make no difference. This is with the "ribbon" version of Excel (they got rid of the Help menu so I don't know how to see what version number it is!). Thanks! Update: The Excel online help says to use ribbon Home tab - Cells - Delete - ... to delete cells. When I select anything on the first row, this pop-up menu is dimmed. So maybe Excel doesn't think row 1 consists of "cells"? Though I don't know what else it would call them. Update 2: I found it, kind of. If I click the "Design" tab in the ribbon, then uncheck "Header Row", then first row becomes a normal row of cells again. Unfortunately, the contents disappear entirely. I want to delete a few cells, not all 50+! And if I copy the first row before turning off "Header Row", it disappears from the clipboard when I uncheck that. So I kind of know what mode it's stuck in, but not a good way out of it.

    Read the article

  • WPF Databinding- Not your fathers databinding Part 1-3

    - by Shervin Shakibi
    As Promised here is my advanced databinding presentation from South Florida Code camp and also Orlando Code camp. you can find the demo files here. http://ssccinc.com/wpfdatabinding.zip Here is a quick description of the first demos, there will be 2 other Blogposting in the next few days getting into more advance databinding topics.   Example00 Here we have 3 textboxes, The first textbox mySourceElement Second textbox has a binding to mySourceElement and Path= Text <Binding ElementName="mySourceElement" Path="Text"  />   Third textbox is also bound to the Text property but we use inline Binding <TextBlock Text="{Binding ElementName=mySourceElement,Path=Text }" Grid.Row="2" /> Here is the entire XAML     <Grid  >           <Grid.RowDefinitions >             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />         </Grid.RowDefinitions>         <TextBox Name="mySourceElement" Grid.Row="0"                  TextChanged="mySourceElement_TextChanged">Hello Orlnado</TextBox>         <TextBlock Grid.Row="1">                        <TextBlock.Text>                 <Binding ElementName="mySourceElement" Path="Text"  />             </TextBlock.Text>         </TextBlock>         <TextBlock Text="{Binding ElementName=mySourceElement,Path=Text }" Grid.Row="2" />     </Grid> </Window> Example01 we have a slider control, then we have two textboxes bound to the value property of the slider. one has its text property bound, the second has its fontsize property bound. <Grid>      <Grid.RowDefinitions >          <RowDefinition Height="40px" />          <RowDefinition Height="40px" />          <RowDefinition Height="*" />      </Grid.RowDefinitions>      <Slider Name="fontSizeSlider" Minimum="5" Maximum="100"              Value="10" Grid.Row="0" />      <TextBox Name="SizeTextBox"                    Text="{Binding ElementName=fontSizeSlider, Path=Value}" Grid.Row="1"/>      <TextBlock Text="Example 01"                 FontSize="{Binding ElementName=SizeTextBox,  Path=Text}"  Grid.Row="2"/> </Grid> Example02 very much like the previous example but it also has a font dropdown <Grid>      <Grid.RowDefinitions >          <RowDefinition Height="20px" />          <RowDefinition Height="40px" />          <RowDefinition Height="40px" />          <RowDefinition Height="*" />      </Grid.RowDefinitions>      <ComboBox Name="FontNameList" SelectedIndex="0" Grid.Row="0">          <ComboBoxItem Content="Arial" />          <ComboBoxItem Content="Calibri" />          <ComboBoxItem Content="Times New Roman" />          <ComboBoxItem Content="Verdana" />      </ComboBox>      <Slider Name="fontSizeSlider" Minimum="5" Maximum="100" Value="10" Grid.Row="1" />      <TextBox Name="SizeTextBox"      Text="{Binding ElementName=fontSizeSlider, Path=Value}" Grid.Row="2"/>      <TextBlock Text="Example 01" FontFamily="{Binding ElementName=FontNameList, Path=Text}"                 FontSize="{Binding ElementName=SizeTextBox,  Path=Text}"  Grid.Row="3"/> </Grid> Example03 In this example we bind to an object Employee.cs Notice we added a directive to our xaml which is clr-namespace and the namespace for our employee Class xmlns:local="clr-namespace:Example03" In Our windows Resources we create an instance of our object <Window.Resources>     <local:Employee x:Key="MyEmployee" EmployeeNumber="145"                     FirstName="John"                     LastName="Doe"                     Department="Product Development"                     Title="QA Manager" /> </Window.Resources> then we bind our container to the that instance of the data <Grid DataContext="{StaticResource MyEmployee}">         <Grid.RowDefinitions>             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />             <RowDefinition Height="*" />         </Grid.RowDefinitions>         <Grid.ColumnDefinitions >             <ColumnDefinition Width="130px" />             <ColumnDefinition Width="178*" />         </Grid.ColumnDefinitions>     </Grid> and Finally we have textboxes that will bind to that textbox         <Label Grid.Row="0" Grid.Column="0">Employee Number</Label>         <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=EmployeeNumber}"></TextBox>         <Label Grid.Row="1" Grid.Column="0">First Name</Label>         <TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Path=FirstName}"></TextBox>         <Label Grid.Row="2" Grid.Column="0">Last Name</Label>         <TextBox Grid.Row="2" Grid.Column="1" Text="{Binding Path=LastName}" />         <Label Grid.Row="3" Grid.Column="0">Title</Label>         <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=Title}"></TextBox>         <Label Grid.Row="4" Grid.Column="0">Department</Label>         <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=Department}" />

    Read the article

  • WPF - List View Row Index and Validation

    - by abhishek
    Hi, I have a ListView with TextBoxes in second column. I want to validate that my text box does not contain a number if the third column(data_type) is "Text". I am unable to do the validation. I tried a few approaches. In one approach I try to handle the MouseDown event and am trying to get the Row number so that I can get the data_type value of that row. I want to us this value in the Validate method. I have been struggling for a week now. Would appreciate if anybody could help. <ControlTemplate x:Key="validationTemplate"> <DockPanel> <TextBlock Foreground="Red" FontSize="20">!</TextBlock> <AdornedElementPlaceholder/> </DockPanel> </ControlTemplate> <Style x:Key="textBoxInError" TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="Validation.HasError" Value="true"> <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/> </Trigger> </Style.Triggers> </Style> <DataTemplate x:Key="textTemplate"> <TextBox HorizontalAlignment= "Stretch" IsEnabled="{Binding XPath=./@isenabled}" Validation.ErrorTemplate="{StaticResource validationTemplate}" Style="{StaticResource textBoxInError}"> <TextBox.Text> <Binding XPath="./@value" UpdateSourceTrigger="PropertyChanged"> <Binding.ValidationRules> <local:TextBoxMinMaxValidation> <local:TextBoxMinMaxValidation.DataType> <local:DataTypeCheck Datatype="{Binding Source={StaticResource dataProvider}, XPath='/[@id=CustomerServiceQueueName]'}"/> </local:TextBoxMinMaxValidation.DataType> <local:TextBoxMinMaxValidation.ValidRange> <local:Int32RangeChecker Minimum="{Binding Source={StaticResource dataProvider}, XPath=./@min}" Maximum="{Binding Source={StaticResource dataProvider}, XPath=./@max}"/> </local:TextBoxMinMaxValidation.ValidRange> </local:TextBoxMinMaxValidation> </Binding.ValidationRules> </Binding > </TextBox.Text> </TextBox> </DataTemplate> <DataTemplate x:Key="dropDownTemplate"> <ComboBox Name="cmbBox" HorizontalAlignment="Stretch" SelectedIndex="{Binding XPath=./@value}" ItemsSource="{Binding XPath=.//OPTION/@value}" IsEnabled="{Binding XPath=./@isenabled}" /> </DataTemplate> <DataTemplate x:Key="booldropDownTemplate"> <ComboBox Name="cmbBox" HorizontalAlignment="Stretch" SelectedIndex="{Binding XPath=./@value, Converter={StaticResource boolconvert}}"> <ComboBoxItem>True</ComboBoxItem> <ComboBoxItem>False</ComboBoxItem> </ComboBox> </DataTemplate> <local:ControlTemplateSelector x:Key="myControlTemplateSelector"/> <Style x:Key="StretchedContainerStyle" TargetType="{x:Type ListViewItem}"> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="Template" Value="{DynamicResource ListBoxItemControlTemplate1}"/> </Style> <ControlTemplate x:Key="ListBoxItemControlTemplate1" TargetType="{x:Type ListBoxItem}"> <Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" Padding="{TemplateBinding Padding}" BorderThickness="0,0.5,0,0.5"> <GridViewRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> </Border> </ControlTemplate> <Style x:Key="CustomHeaderStyle" TargetType="{x:Type GridViewColumnHeader}"> <Setter Property="Background" Value="LightGray" /> <Setter Property="FontWeight" Value="Bold"/> <Setter Property="FontFamily" Value="Arial"/> <Setter Property="HorizontalContentAlignment" Value="Left" /> <Setter Property="Padding" Value="2,0,2,0"/> </Style> </UserControl.Resources> <Grid x:Name="GridViewControl" Height="Auto"> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="34"/> </Grid.RowDefinitions> <ListView x:Name="ListViewControl" Grid.Row="0" ItemContainerStyle="{DynamicResource StretchedContainerStyle}" ItemTemplateSelector="{DynamicResource myControlTemplateSelector}" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Source={StaticResource dataProvider}, XPath=//CONFIGURATION}"> <ListView.View > <GridView > <GridViewColumn Header="ID" HeaderContainerStyle="{StaticResource CustomHeaderStyle}" DisplayMemberBinding="{Binding XPath=./@id}"/> <GridViewColumn Header="VALUE" HeaderContainerStyle="{StaticResource CustomHeaderStyle}" CellTemplateSelector="{DynamicResource myControlTemplateSelector}" /> <GridViewColumn Header="DATATYPE" HeaderContainerStyle="{StaticResource CustomHeaderStyle}" DisplayMemberBinding="{Binding XPath=./@data_type}"/> <GridViewColumn Header="DESCRIPTION" HeaderContainerStyle="{StaticResource CustomHeaderStyle}" DisplayMemberBinding="{Binding XPath=./@description}" Width="{Binding ElementName=ListViewControl, Path=ActualWidth}"/> </GridView> </ListView.View> </ListView> <StackPanel Grid.Row="1"> <Button Grid.Row="1" HorizontalAlignment="Stretch" Height="34" HorizontalContentAlignment="Stretch" > <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center" Orientation="Horizontal" FlowDirection="RightToLeft" Height="30"> <Button Grid.Row="1" Content ="Apply" Padding="0,0,0,0 " Margin="6,2,0,2" Name="btn_Apply" HorizontalAlignment="Right" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Width="132" IsTabStop="True" Click="btn_ApplyClick" Height="24" /> </StackPanel > </Button> </StackPanel > </Grid>

    Read the article

  • MySql - Get row number on select

    - by George
    Can I run a select statement and get the row number if the items are sorted? I have a table like this: mysql> describe orders; +-------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------------------+------+-----+---------+----------------+ | orderID | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | itemID | bigint(20) unsigned | NO | | NULL | | +-------------+---------------------+------+-----+---------+----------------+ I can then run this query to get the number of orders by ID: SELECT itemID, COUNT(*) as ordercount FROM orders GROUP BY itemID ORDER BY ordercount DESC; This gives me a count of each itemID in the table like this: +--------+------------+ | itemID | ordercount | +--------+------------+ | 388 | 3 | | 234 | 2 | | 3432 | 1 | | 693 | 1 | | 3459 | 1 | +--------+------------+ I want to get the row number as well, so I could tell that itemID 388 is the first row, 234 is second, etc (essentially the ranking of the orders, not just a raw count). I know I can do this in java when I get the result set back, but I was wondering if there was a way to handle it purely in SQL.

    Read the article

  • Ext GWT (GXT) tooltip over a grid row

    - by Eduardo Palma
    I'm developing a custom tooltip using Ext GWT (GXT) for a project of mine, and this tooltip has to appear over Grid rows when they're selected. I can't use the default GXT tooltip or quicktip because I need be able to add Components (like buttons) to this tooltip. The problem is that the GXT Grid component doesn't expose a event related to mousing over a row (although there's RowClick and RowMouseDown). I tried adding a listener to the Grid with the OnMouseOver and OnMouseOut events anyway, but it doesn't work as expected. It fires these events up whenever you mouse over any of the divs and spans that composes a row. The only way I see to solve this is to subclass the GridView component and make each row become a Component itself, but that would be a lot of work and would probably impact performance as well. I can't help but think there's a better way to do this. Could someone more experienced with GXT give me a light?

    Read the article

  • Oracle analytic functions for "the attribute from the row with the max date"

    - by tpdi
    I'm refactoring a colleague's code, and I have several cases where he's using a cursor to get "the latest row that matches some predicate": His technique is to write the join as a cursor, order it by the date field descending, open the cursor, get the first row, and close the cursor. This requires calling a cursor for each row of the result set that drives this, which is costly for many rows. I'd prefer to be able to join, but what something cheaper than a correlated subquery: select a.id_shared_by_several_rows, a.foo from audit_trail a where a.entry_date = (select max(a.entry_date) from audit_trail b where b.id_shared_by_several_rows = a.id_shared_by_several_rows ); I'm guessing that since this is a common need, there's an Oracle analytic function that does this?

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >