I've been looking for a way to do something and I'm convinced I've been using the wrong search criteria to finding a solution...so, here I am.
I have a dropdown menu in a content management system that when a new page is created or position is edited, the database is updated with the new or edited value...this is all working great.
However, what I'd like to do is...when a number for the page position is changed from let's say, position 5 to position 1...the former position number 1 is changed to position number 2...and every position number for any pages remaining are renumbered accordingly.
So, my question is, how do I UPDATE my database so, whenever I change the position of the page in the dropdown menu, ALL position values get, I don't know, a +1...or something...and additionally, NOT allowing two position values to be the same...you know, there can be only one...
Thanks in advance...hope I didn't do too bad in explaining what I'd like to do :-)
Have you tried something like:
UPDATE my_table SET position=position+1 WHERE position>2 AND position<5
The where statement should be the new position & old position of the one you've just updated
Related
I have a DataGridView which is bound to a SQL result. Afterwards I add three DataGridViewComboBoxColumns manually, which are populated by corresponding SQL results.
When choosing an entry from each of the DataGridViewComboBoxCells, the ValueMember is saved to the database.
As soon as the DataGridViewComboBoxColumns are added, a preselect function is called, which reads the selected values from the database, to always see the last state.
Until now everything is working as expected.
The problem is, as soon as I sort the DataGridView by clicking on any of the column heads, the DataGridViewComboBoxCells are not preselected any more.
So, I thought, by adding a .Sorted event handler which calls my preselect function would solve this problem. But the selection is not done any more.
function PreselectComboBoxes(int IdJob) {
foreach (DataGridViewRow row in dataGridViewHotels.Rows)
{
... // iteration through all rows and set value read from database by reading ID number from first column
}
}
As the ID for the database can be read directly from the row, I do not see, why it does not work this way.
Thanks in advance for any ideas.
Is there a limitation with the number of values within an angular orderby predicate? I can't get anything with more than 2 fields to work. Meaning anything past the 2nd index doesn't work. If I shift the fields around and put the one that is 3rd to first it works.
Example:
['VendorName','ProductName','-ProductCost']
The value in the 3rd position or index 2 appears to be ignored unless i move it within the 1st or 2nd positions of the array. I could be completely overlooking something, but I can't get it to work. The first two fields work fine.
Any info would be greatly appreciated.
Seems to work correctly in this Plunker:
http://plnkr.co/edit/nHBQrJKXuGNkZ55VNPl8?p=preview
Click the Sort Name, Phone, Age button.
I am trying to print a report where we have several different components within the xaml.
By what I`ve found, when printing, you have to treat every UIelement as a single one, thus if the desiredSize is bigger than the AvailableSize you have to activate the flag HasMorePages.
But here comes the problem.
My user can write as much text as he/she wants on the grid, therefore, depending on the amount, the row expands and goes off the printable area, as you can see on the picture below.
I thought about giving a whole page to the grid, but it was to big still, which got me into a loop where the DesizedSize was always bigger than the PrintableArea.
My code is not very different from any source you find on internet when searching for Multiple Page printing.
It is based on this http://eswarbandaru.blogspot.com.au/2011/02/print-mulitple-pages-using-silverlight.html , but using Stackpanels instead of Textboxes.
Any idea?
Thank you in advance.
First you need to work out how many pages are needed
Dim pagesNeeded As Integer = Math.Ceiling(gridHeight / pageHeight) 'gets number of pages needed
Then once the first page has been sent to the printer, you need to move that data out of view and bring the new data into view ready to print. I do this by converting the whole dataset into an image/UI element, i can then adjust Y value accordingly to bring the next set of required data on screen.
transformGroup.Children.Add(New TranslateTransform() With {.Y = -(pageIndex * pageHeight)})
Then once the number of needed pages is reached, tell the printer to stop
If pagesLeft <= 0 Then
e.HasMorePages = False
Exit Sub
Else
e.HasMorePages = True
End If
Or if this is too much work, you can simply just scale all the notes to fit onto screen. Again probably by converting to UI element.
Check out this link for converting to a UI element.
http://www.codeproject.com/Tips/248553/Silverlight-converting-to-image-and-printing-an-UI
Hope this helps
Using Access 2010. Fairly new to automation and macros.
I have two tables (tblProductReceived and tblBins) and a form (frmProductReceived).
A field in tblBins corresponds to a location the bin is at (named BinLocationID) and the tblProductReceived table tracks product that a specific bin has received.
What I need is for the tblProductReceived field PRLocationID ([tblProductReceived].[PRLocationID]) to be automatically populated with where the bin is at ([tblBins].[BinLocationID]) when selecting a specific bin in the form (frmProductReceived).
Is there an easy way I can do this? I'm really new at macros/vba and I would extremely be grateful for some tips/suggestions!
Also, there is no object in the form for the PRLocationID field. I want it to be updated behind the scenes based on the bin number field the user selects ([tbl.Bins].[BinID])
Here are images of tblBins, tblProductReceived, and frmProductReceived: http://imgur.com/a/0IUHm/ (can't post images quite yet without reputation)
See this is the structure i have:
tblProductReceived is a table that records items that were deposited into bins.
tblBins is a listing of physical drop locations (bins) that contain a field BinLocationID
BinLocationID actually corresponds to another table (tblLocations) that has all the locations.
But I can't simply link the field from tblBins to tblProductReceived's because sooner or later bins can move from location to location (whatever the reason is is unimportant). This is the reason why I need a copy of [tblBins].[BinLocationID] to be copied over to [tblProductReceived].[PRLocationID] because should a bin move, it would mess any analysis (as we want to keep track of where the product was dropped off at, not only the location of the bin).
Also, the form I set up does have the drop down to the various bins ([PRBinID] in [tblProductReceived] — (i use a lookup query on tblBins) but keep in mind there is no txtBox for the PRLocationID in the field as it's superfluous. The bins are at location already, all i need is for it to be copied over to the appropriate table.
Am i overlooking anything?
After picking at it for hours this is the most elegant solution I've come up with:
On the form, I have a hidden txtBox called txtPRLocationID whose row source is PRLocationID (in tblLocations)
After a bin is selected at txtPRBinID, i have an event scripted at Lose Focus:
'Private Sub txtPRBinID_LostFocus()'
'[txtPRLocationID].Value = DLookup("[BinLocationID]", "tblBins", "BinID = " & Nz(Me!txtPRBinID.Value, 1))'
'End Sub'
Basically what it does is everytime a value is selected for txtPRBinID and the user moves on (Loses Focus of the txtBox), a DLookup occurs for tblBins.BinLocationID for the value of BinID and changes the value of txtPRLocationID text box.
The 'Nz()' is to avoid Null errors (according to Google search). Not sure if necessary, if anyone can confirm, please do!
Thanks for reading!
I am trying to get forward and backwards pagination working for a query I have on my app.
I have started with the example at: https://developers.google.com/appengine/docs/python/ndb/queries#cursors
I would expect that example to do a typical forward/back pagination to create cursors that you can pass to your template in order to be used in a subsequent request for the page after/before the current one. But what it is doing is getting cursors for the same page, one from the beginning and the other from the end (if I have understood correctly).
What I want is a cursor to the beginning of the following page, and a cursor to the beginning of the previous page, to use in my UI.
I have managed to almost get that with the following code, based on the mentioned example:
curs = Cursor(urlsafe=self.request.get('cur'))
q = MyModel.query(MyModel.usett == usett_key)
q_forward = q.order(-MyModel.sugerida)
q_reverse = q.order(MyModel.sugerida)
ofus, next_curs, more = q_forward.fetch_page(num_items_page,
start_cursor=curs)
rev_cursor = curs.reversed()
ofus1, prev_curs, more1 = q_reverse.fetch_page(num_items_page,
start_cursor=rev_cursor)
context = {}
if more and next_curs:
context['next_curs'] = next_curs.urlsafe()
if more1 and prev_curs:
context['prev_curs'] = prev_curs.reversed().urlsafe()
The problem, and the point of this question, is that I use more and more1 to see if there is a next page. And that is not working in the backwards sense. For the first page, more1 is True, in the second page more1 is False, and subsequent pages give True.
I would need something that gives False for the first page and True for every other page. It seems like this more return value is the thing to use, but maybe I have a bad Query setup, or any other thing wrong.
Thanks everyone!
Edit: Since I didn't find a simple solution for this, I switched to using ndbpager.
There's no such thing.
You know thats theres (at least) one page before the current page if you started the query with a cursor (the first page usualy dosnt have a cursor).
A common trick to access the previous page is inverting the sort-order.
If you have a list, sorted by creationdate desc, you could take the creationdate of the first element of your current page, query for elements with creationdate < this creationdate using inverted sort order. This will return the oldest elements which are newer then the given creationdate. Flip the list of retrived elements (to bring them into the correct order again) and there you have the elements of the page before, without using a cursor.
Note: this requires the values of your sortorder beeing distinct.
In some cases, its also possible to use a prebuild index allowing random-access to different pages, see https://bitbucket.org/viur/server/src/98de79b91778bb9b16e520acb28e257b21091790/indexes.py for more.
I have a workaround and not the best solution. it is baiscally redirecting back to the previous page.
Previous
I think PagedQuery has the capability but still waiting for someone to post a more comprehensive tutorial about it.