I've got an hover table with several pages, each row has some action that one can perform with an item.
Whenever one of those actions is performed the page refreshes and the website comes back to page 1 of the table. Is there a way to remain in the same page where I last executed an action on a row?
Thanks in advance.
I was already able to solve this problem, I was not being very precise in my google search and once I changed that I was able to find a pretty simple solution:
$(document).ready(function(){
$(#tableid).DataTable({
stateSave:true
});
});
Related
I'm working on a website where you can see buildings on a map and where users can click on a table row (1) (where informations about the building is shown) to get redirected to the map page. Additionally, and thats where i'm stuck, the clicked table row should appear on the first page (2).
So the question is: how can i display the table row that just got clicked, on another page?
thanks for your help!
Pass the index of the row that is clicked as props
Even if it's difficult to answer to this question since it's very generic, I'll try to assume that you are missing the basic approach and need a starting point on how resolve this. Once you clicked on the row, you can pass the data to the new URL. Assuming that you are calling a new page, the row should be wrapped in an anchor element and in this case the data can be passed with a GET request, included in the URL. You can have a look to the W3school website page talking about GET method
to learn more about it.
If you are trying to do this as a single page application with react instead, start looking at React documentation on how components and props work to pass props down to other components.
Hope you find this helpful!
Current working code to go back one page:
onclick="location.href=document.referrer; return false;
This code allows me to go back by one page only. Are there any code snippets that would allow to go back multiple pages similar to a browser's back button?
I understand there is a go() method to use with window.history.go(-i) but that doesn't solve the need. I am hoping to show a list of pages visited for a user to click on the desired page. This is similar functionality to a browser's back button.
In essence, trying to go back sequentially instead of jumping back x number of pages.
Thanks in advance for all of your inputs.
Ok so i have a problem. I have a grid with about 5 columns.
They are:
TaskQueryID, Comment1, Comment2, TaskID, ProjectName.
Data is loaded via WebAPI and everything is dandy.
Every cell in the grid runs off same template which turns the text in the cell into a link. The point of it is to the use that link to load more information about that row into the same grid. This works as expected as well.
The problem i have is when i sort the columns. During initial load, the data shows, i click lets say 3rd row link, i get correct detailed data. I reload the page, try it again, works fine. THEN i repeat the test but after load i sort by random column (i tried all of them) and click said 3rd row link again and i get a problem. Data shows up but not for the sorted 3rd row link but for the original load 3rd row link.
The underlying data is not sorted, just the UI?
I'm a bit stumped.
Solved it. Turns out the parameters were referenced from the grid scope instead of the current click scope. I'm just getting into Angular so this difference eluded me. Hope this helps somebody!
I have problem in shifting from one tab to another in HTML. I have two tabs, #tab1 and #tab2. I have one form in each of the tabs. when I enter details in #tab1, come to #tab2 and again go back to #tab1, the data I entered is not getting refreshed. The old values are retained back. I want a refreshed form.
I tried reloading the page itself by giving -
window.reload(true);
Whwn I did this, the page is displaying and disappearing within a fraction of second.
And also, tried refreshing the form alone by giving -
$('#formID').reset();
Then, the tab itself is not working. I am not getting any exceptions here. I am using jquery for shifting tabs.
Can any one please help me out in tracing out this problem?
Consider this:
$("tabIdHere").click(function(){
$('#formID')[0].reset();
});
Try this one ..
$("tabIdHere").click(function() {
$(this).closest('form').find("input[type=text], input[type=password],textarea").val("");
});
Clear form fields with jQuery check here too
I am creating a dynamic table control with ASP.NET/C# and the table is being used to hold a form. I need to allow users to click on a button in a row and make a duplicate of that row right below the original. My page is also using AJAX and jQuery.
I have tried to use Table.Rows.AddAt(indexoforigrow+1, newrow) but I get an error that the index is out of the range of values. I figured maybe I wasn't getting the original row's index correctly so I just tossed in a 1 and still got the error.
I also noticed that when I press the button to execute the code, the table disappears. Any ideas on how to fix that?
I am thinking that if I am unable to get these issues fixed I will have to loop through the table and submit the data to a temp table, adding a new row where indicated. Then I would pull all of the data back out and display again.
EDIT
I moved on when I could not get this working and tried to setup my submit functions to loop through the data and submit it to a db and realized that I am experiencing the same issues when clicking the submit button as when I click the add row button. It appears that my issue is really with viewstates/postback.
I did some reading on this and from what I can tell the solution is to re-create the dynamic control on page load every time. But I am confused about how I can do this if I have no idea how many rows/cells I have and how is the information the user entered kept in the form? I have no way of saving the information to a DB or anything because as soon as submit is clicked it all disappears.
Have you considered using a different control? One of the grid controls might better serve your purpose.
I've handled situations (that sound) similar to what you're describing by using the footer of a GridView (among other ways). The big trick is to bind the display object (Table, GridView, etc.) to a list of objects. Then you manipulate the list of objects, rebinding the display object after the list has changed.
You will need to persist this list in some manner, or you could wind up with the list being reset to null. One way would be to save it as part of the session.
At any rate, the idea is to have a display object (GridView) bound to a list of objects. When the user clicks 'add', an item is added to the list. Save the list, then call the GridView.DataBind method.
You are on the right track with re-creating the dynamic table each time the page loads. I have dome similar things and my solution was to keep a client state in a hidden field on the page. Every time you add a row to the table on the client, increment a counter or adjust the state data in the hidden field. Then, on the server-when the page posts back, read from that hidden field to know how many rows were added on the client. You will have to use some kind of naming convention for the new rows you add(and the widgets in them) so you can re-create them on the server.
A simpler option may be to use an UpdatePanel. Rather than try to add the rows on the client, your "add row" button would cause a partial update. The server side code would add the new row to the table and the viewstate would be updated.
I ended getting my data guy to do a bit more processing on his end so that I could just bind a ListView to a sproc. Solved a few of my problems.
Thanks for the helpful comments.
Just returning to this almost a year later because I faced a similar issue in my current project. I was doing a few things wrong my first time around. First, I did indeed need to recreate the controls every load, but I also had to create them earlier in the page cycle. I was trying to create them during page load, which is after the viewstate is loaded.
The controls need to be recreated with the same ID before viewstate is loaded. I went with page init and it worked fine.