Here's my use case:
I'd like to display the information about something first using django_tables2, with a button on the top right corner called "Edit", once a user hits "Edit", at the bottom of the table, display a button called "Add New Record", and once the user clicks that button, a bunch of input fields pop up to let users enter values for each field, also the user could continue to click "Add new Record" to keep adding new.
How can I achieve this in Django?
I've read a lot of examples on stackoverflow but didn't find anything tailored to this particular case.
Thanks a lot.
Let's dive right into listing out what you want to do and the requirements you'll need to do so.
You basically want to toggle hiding and showing some functionality for this web page. This is easily accomplished by including the "Edit" button, "Add New Record" button, and popup (most likely in its own <div> somewhere in the page). So the "Edit" button will have the display set to something, be it inline, block, etc., while the "Add New Record" and popup would have a display of "none" or however it is you wish to hide it.
You've got the stuff set up and ready to go but now you need to show it when you click the "Edit" button. This is generally accomplished through Javascript. Just find the "Add New Record" button and switch the visibility.
When you click on the "Add" button you want to display a popup. This can be done in a variety of ways with different libraries. One of my personal favorites is using jquery's blockUI. Why? It doesn't allow the user to click anywhere except in the popup so it's a quick way to handle users trying to reach outside the scope of the popup.
So you've got all the new rows added and you are done editing. Maybe you have a "Save" button or something like that where you can click. When you do, you'll want to push all those new rows you just added to the database. Django handles this well and you could do something like include the new rows in part of the POST request or however you care to implement this solution.
So there's a bit of work ahead of you to get this page up and running with the exact functionality you need but hopefully this starts steering you in the right direction of where you need to go.
Related
I have been struggling with this for a while now. I'm trying to navigate to one tab (let's say Home) to another (let's say About). I'm able to navigate that either the page get's added to nav stack, but then it's not changing active tab. That, or then we use select to set the active tab, which means that I lose the navigation stack. Here's the latter option code:
export class HomePage implements OnInit {
tab: Tabs;
constructor(public navCtrl: NavController) {
this.tab = this.navCtrl.parent;
}
navigate() {
this.tab.select(1);
}
But this means that as mentioned, I lose the nav stack and can't use the back button that would show if I use push. That brings us to the other option, when I use .push():
this.navCtrl.push(About)
The active tab won't change, but still shows Home as the active tab, even though we are successfully navigated to About tab.
So what I wish for, is to have both the 'Back' button and the active tab (About) selected when I'm clicking the button to go to About from Home. Here's a demo with the push option, as you can see the active tab does not change: https://plnkr.co/edit/6KIL8mxfTMCsvACpiD1K?p=preview
PS. I looked at this question, but it wasn't useful to me: Changing tabs dynamically in Ionic 2
I'm using Ionic 3
I don't think this is how the tabs component is intended to work. With tabbed navigation you kind of have n navigation stacks (where n is the number of different tabs you have) which means if you .push() a new page on the nav-stack you push it on the stack of the currently selected tab.
Switching to another tab kind of is the same as starting with a new root, you start with the initial page ([root]="yourFirstPage") and can then add new pages to this particular nav-stack (and you can pop them off the nav-stack with a back button).
In you particular example you are trying to .push() the About page on the stack of the Home page and expect the NavController to know that you intended to switch to another stack and to push a new page to the new stack.
One solution to your problem could be to always remember the previous tab when you use .select() and display back button manually in the navbar which uses .select(previousTab) on click.
I hope that makes things clearer for you.
It's the default behaviour to act like this. When you select a tab it clears the nav stack and set the root to another page. When you push your about page when in home page you're pushing a new page in your home nav stack, this is why it doesn't change and shoudn't change.
The reason to use tabs is that you can segment and divide stuff in they correct categories. When updating a product you don't whant the user the see, for example, billing information in the same stack of products since it doesn't belongs to that category.
The .select() method (whose you've implemented in your home.page.ts) is the closest you can have from beeing able to select a tab without clicking in a specific tab.
What you can do is simply remove about from beeing a tab and push it in home OR remove the button to go from the home to about page, since there's already a tab for this.
In any case what you want to do is an error that Ionic team removed the possibilities from people doing.
Hope this helps you.
We have a rendering listing the selected items in a TreeSelect in the current item. In our case we call them "Tags" (1)
We have added a Field Editor Button to the component to let the editor change selected items. (2) (As described on for example Adding a custom component)
When an editor clicks (2) the editor window (3) it is opened in a dialog. The editor may select different items(called tags in our case) using the TreeSelect.
When the editor presses the ok-button (4) the values are set.
Now to the problem:
The values are actually set as they get stored when the editor presses the Save button but we want our list on the page (1) to immediately reflect the set items when the editor presses the ok-button (4), i.e. before having to actually save the whole item.
How do we achieve that?
(I am in contacts with Sitecore support but so far I have not gotten any answers...)
Update
After a lot of conversation with the support we still have no useful solution.
We tried turning it into a field renderer displaying the links.
What worked was:
The field do get updated when you have edited it in the popup field editor. (but...)
It looks good the first time when page is loaded.
You can make a WebEdit button with commands to edit the field and add it as Custom button to the field (register <command name="webedit:fieldeditor" type="Sitecore.Shell.Applications.WebEdit.Commands.FieldEditor, Sitecore.Client"/> and set Click on the button to webedit:fieldeditor(command={3473DDA1-2983-493C-AF7A-054C75AA7AD3},fields=NameOfField where the guid points to itelf and an "Icon" is set on it.)
What didn't work was:
The field get updated by the raw value, not what I want to display. Server code is involved, but not in the rendering of html-code.
When I want to edit the value in the field editor, the value sent to the field editor is not the raw value but what actually is displayed on the page. (I guess this can be solved somehow)
The issue to the support turned into a feature request to let the server be involved in rendering the field, not just sending a new value to the JavaScript updating it. The server does the first rendering so when it already is involved in updating, it should be allowed to do the rendering the following times too.
We have decided to not spend more time on this right now (we have other things to do too.) and have a bad editor experience as the field not get updated until the editor actually saves the item.
Still we have no suitable solution for this issue. If you want to keep working on it and want a reference to my issue it is 439059.
This may not be useful here. I've done this in normal sites, but not in Sitecore. But, here's one possibility....
This is a situation where you would pass a callback function to the child popup window. This callback will cause the caller / parent window to re-read/re-load the information that was just updated by the child.
Example:
User presses (2) to open Editor Window(3) (Editor window is opened and the Callback function is passed as a parameter)
User presses "OK" button (4). The "OK" button event handler updates the changes, then calls the Callback function which re-loads the now updated information, and closes the popup window.
Once the popup closes, the parent window now displays the information that the popup/editor just updated.
This takes some client side javascript (jquery) development but it is quite do-able normally.
I've been translating a theme by simply customizing the HTML, but I've run into a problem:
The "Add to cart" button on a product page. I can translate the label on the button, but when you click the button the text changes from "Add to cart" to "Adding..." and then to "Added!".
Neither "Adding..." nor "Added!" are anywhere to be found the HTML of the theme, so I'm wondering where I should look if I want to translate those?
The "Adding", "Added" response comes from the theme's javascript - unfortunately that's hard-coded in and there's not a way to change it. You may want to try modifying another theme that doesn't use ajax to add products to your cart, like Sexy, Luna, or Nova - then you should be able to have more control over translating your store completely.
I would like to display a confirmation message after a choice in the menu.
For example if you want to delete an image in the Timeline, you tap on the glass to open the menu, you select "Delete", you have a progression bar to cancel if you want, when the progressbar is complete a kind of toast appear to say "Deleted" and disappear.
I would like to reproduce only the "Deleted" part but I've searched everywhere and cannot find a way to do it. Is there an API or should I manually implement it with a layout containing the text wanted and display it for 3 seconds... ?
Thanks
There is no API for this to work you will need to build a layout and then set it as the current view using setContentView for a specific amount of time and then return to your main view.
I have a list of links within a div with a scrollbar. When the user clicks on a link below the x-height of the div, the srollbar automatically goes back to the top. I would like the scrollbar to stay in position no matter what links the user clicks. Here is the site- try clicking on a painting from 2006 and you'll see what I mean.
Does anyone have any ideas of how I can make this scrollbar behave?
Thanks,
Brad
It looks like these links are just that, links to a new page... and thus it's not so much that the scrollbar is resetting but that a whole brand new page is coming up and the 'reset' scrollbar is just a byproduct.
The most elegant way would be to have those links pull in the new content without reloading the page, but this requires AJAX. If you aren't familiar with the intricacies of AJAX and how to implement that, then you could change the link to include an anchor to the link, like so:
http://siddharthparasnis.com/2006-01/#menu-item-377
The page would reload scrolled down to that item.