I have a Dojo Grid. Every row has a link to the formular, where the data can be changed. Now, when I click save and close (in the form) I want the grid to reload the displayed data. So far, I've managed to reload the data, but I always jump back to the start of the grid. But, e.g. if I'm at the end of the table, I want to reload just the last few entries.
My grid is connected to a JSONRest Store, so basically I just should know the range which is displayed right now... . How do I get the range?
If you have backed your grid by a store, you simply "put" the changed object to your store. The JsonRest store you are using will send the changes back to your server with a PUT request and the grid will pick up the changes and update the corresponding item.
When pressing save in your form, you would need to create a json representation of your form data (that matches the one used in the grid) and put this to the store:
require(["dojo/dom-form", ... ], function(domForm, ...) {
...
var updatedItem = domForm.toObject("yourFormId");
yourGridStore.put(updatedItem).then(function() {
console.log("put was successful");
});
...
}
I've managed to solve the problem without any put to the store. Here is the code:
grid._lastScrollTop=grid.scrollTop;
grid._refresh();
And here is the link where I've found the answer. It is the answer number 6.
Related
I'm trying to build a way to update a user profile one question at a time.
Essentially I want a div on my page that displays a form that lets the user submit the most important information, say firstname. When that has been filled out (success on the form) I want to refresh that div and show the second most important form, for say lastname, or if that is already filled in then birthday and so on.
Much like linkedin prompts you to add one more piece to your profile.
How would you do it?
My first thought was to use elements. But I need to fetch existing profile data to populate the form and how would the element get that data, abusing requestAction is not an option.
So I guess I in that case need to call a controller action that determines which element should be rendered, renders it to a variable and submits that (response->body) in json to the js that updates the page. Seems a bit .. unclean but should work.
Then we have view cells. They seem ideal for the task until I want to call them via ajax. That is not possible right?
So how would you go about to build something like that?
A form that needs to have the ability to be prepopulated with data if there is any and then refreshed automagically to display the form for the next piece of info needed.
View cells can't really be used in AJAX requests. This is not what they thought for.
The best thing you could do, if you want to keep the cell, is to make sure you followed SoC properly and put all your business logic into the model layer.
Now have a separate controller and action that is reachable from the outside throught a request (a cell is not) and return the data as JSON from there using the same code.
You could try to instantiate the cell in the controller action as well and send it's output. But honestly, I think that's a pretty fugly way of doing it.
I have access a webpage with a list of several hyperlinks, each of which are unique. This is it:
webpage I have access to that lists names from top to bottom. Each name is unique and is a hyperlink. I would like to click on these hyperlinks one by one and extract info from the resulting webpage.
Say I click the first name, say Adam, it then brings me to the following webpage:
alt:this is a page of the user's profile and includes info such as name, email status and more
My goal is to create a program that clicks the name at the top, and then takes the email address and puts it in an excel spreadsheet on my local machine. And then goes back to the original page, clicks on the name directly below the name that was previously clicked on, and then takes this names resulting email and throws it in the spreadsheet.
for those looking at the pictures, i would like to click on 'Adam' and then put his email into a spreadsheet, then go back, and then click on 'Adrian' and then put his email into a spreadsheet, and so on and so forth down the list.
What do I need to do/learn to create a tool that will do this for me?
I know a bit of Java and a tiny bit of html. I've been trying to look for a solution but the most I can get is excel vba to click on the first name, but not much more. Even if I got the vba to click on all the names, it seems I would have to type in an instruction for the vba to find each unique name, and I dont see much point in doing that since its probably faster to just do this manually then.
As i'm not a programmer (but would like to be soon :)) I have had some trouble asking this question since I don't know any technical terms.
Any thoughts/advice on how to do this?
With javascript and a little php you could make this happen. Since it appears this is something running in the browser it would probably be your best bet.
Make your program click links js has the ability to activate links. You could
click on body load
the first link on the page,
then have a counter that counts each time you click a link.
`Find out how many links there are in the document:`
var x = document.links.length;`
`Get the URL of the first link (index 0) in the document:`
`var x = document.links[0].href;`
Click the link you want to click
$(function(){
$('#myLink').trigger('click');
})
now that your on the next page you need to grab the email address that is on this page. If you know the css just grab the string that is in the element. at this point you can use javascript to go back to the previous page.
<button onclick="goBack()">Go Back</button>
Now you are on the original page. Your counter is one number higher. Use the counter to click the next link and your program will repeat the process pushing the new email to your array.
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
once the program runs out of links to click or hits the limit of your counter you will need to create a txt file with javascript. write your array to the file with PHP. You can do this with an ajax call.
make an AJAX call to your php file passing the array. php can then write to the file.
Here is an example of making a text file and writing to it with javascript
Following this logic you can fairly easy make an application that activates the links in order of a page, pushes the email address to an array as a string. Goes back to the previous page and continues the process till you have all the links. At this point your program will write all the data in the array to a file.
I'm doing one windows phone 8 application. In this I've used list box. For the very first page I'm getting the data from server and adding that data to list box. Now I want to add Show More at the bottom of the list box i.e after the last item, to get the next items from the server.
How could I achieve this?
Hear you have to use Horizontal scrolling for load next data
Check below tutorial
Detect when a ListBox scrolls to its end (WP7)
Windows phone tutorial:Listbox
WP7 – How To Extend ListBox When Reaching Last Item
Windows Phone 7 ListBox Pagination with MVVMLight & ApplicationBar
we can Gets or sets the amount of data to fetch for virtualizing/prefetch operations by using
ListViewBase.DataFetchSize property and can Initiates the asynchronous request to load more data items, in accordance with the active incremental loading settings by ListViewBase.LoadMoreItemsAsync method.
If you want to do it by pagination then the following links may be helpfull for you
DataFetchSize method
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.listviewbase.datafetchsize.aspx
LoadMoreItemsAsync method:
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.listviewbase.loadmoreitemsasync.aspx
You can see examples of using these here (though note that the sample was based on Windows 8 BUILD release and the apis have had some changes)
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/e71b7036-4fb7-4963-a65d-5bcb9fd8f664
I'll go ahead posting the logic as My code might not match with yours
So
1 -> Save the server data in an array or a list.
2 -> Design the xaml in a way that the Parent Grid has two or more rows with the last row for the show more. And the one before for the list. (Adjust height accordingly)
3 -> Populate it with a limited amount of data.
4 -> Next use the ListBox.Items.Add(data) method to add the data to the list. Keep sorted property off so that the elements are inserted at the bottom of the list
-> Go through the link Add Method for Observable Collections
Use step four on the show more button click .. and also adjust the height of the list or put it into a scrollviewer so that limited height scrolling can be done . olease update if further queries
I'm currently using Perl CGI to display some internal billing pages at work. I'm using JQuery as well to add a little 'spunk' to it if you will.
I'm looking to generate/display HTML based on drop down selection by the user. Now, I can handle this part no problem. I'm generating table rows/table data on click based on the selection made by the user.
I want to retrieve and display values stored in the database for the corresponding data im displaying on button click, and without refreshing the page of course.
Can someone point me in the right direction? Thanks in advance.
You'll want to use an AJAX request to get the data. So, for example, if you have a select with class 'ajax' and you want to display data based on the option selected, you can do something like:
$('.ajax').change(function(){
$.get({'url', { value: this.val() }, function(data){
// display the data with a .html() or .append() or something
});
});
Replace 'url' with the url of a page that queries the database using the value that you send it.
HTML form has some text boxes and a drop down box.
Drop down has huge values, and takes lot of time to fetch from database.
So I want to load the page first and while the user fills the form (text boxes) I want to load the drop down box (without his knowledge :-) ).
But without any event trigger, how do I make call to database again ?
I am using JSF with RichFaces, Servlet.
The following code is not working
<h:selectOneMenu value="#{obj.selectedValue}">
<f:selectItems value="#{obj.allValues}" />
<a4j:support selfRendered="true" action="#{bean.action}"/>
</h:selectOneMenu>
Thanks,
+1 for using Ajax - but if you have a very large number of values,t hen you might want to consider using an auto completion dropdown - where the the user starts typing what they need and after they have typed a few characters, you kick off your ajax reqeuest and just load those requests that match.
have a look at "google suggest" if you want to see this in action
-Ace
As already mentioned you can use AJAX to load the dropdown items asynchronously, but I would suggest redesigning the form so that the huge dropdown is not required. Perhaps let the user search for the correct value on a previous or subsequent screen? Long dropdowns are not easy to use as they require lots of scrolling and it can be hard to find the correct value on a large list.
At the bottom of your page put the following:
<a4j:jsFunction name="yourJsFunction" action="#{bean.fetchSelectItems}"
reRender="yourDropdown" />
window.onload = yourJsFunction();
You will have to use AJAX. When the page loads display a empty select box. Then write some JavaScript that will call some URL on your server that will return the options for the select box. And when you get that just populate the select box with those values.
Be advised that your form will be useless to those without JavaScript.