So i have a function on my main page that builds the grid, and a hyperlink that rebuild the xml file, then creates the table, however, i have to close my browser to get the new data, even though the new data was written to the xml file.
joe
Friday, June 19, 2009
Ok here is a little more explination on what i am trying to do.
O i have a function that takes 1 paramter, this is used in what xml file to get.
so
function creategrid(my_xml_file_prefix)
{
do grid stuff
}
so how do i refresh my grid?
Ive seen this below, but i cant run that since i dont know where to put that code, or what i pass it etc.
function clearGrid(){
obj.clearCellModel();
obj.clearRowModel();
obj.clearScrollModel();
obj.clearSelectionModel();
obj.clearSortModel();
obj.refresh();
}
joe
Friday, June 19, 2009
function creategrid(my_xml_file_prefix)
{
clearGrid();
do grid stuff
}
Saturday, June 20, 2009
that dosent work...
joe
Saturday, June 20, 2009
where do i put this in my code?
i cant pu that in my create grid function, i cant put it outside, since its not binded to the grid object
function clearGrid(){
obj.clearCellModel();
obj.clearRowModel();
obj.clearScrollModel();
obj.clearSelectionModel();
obj.clearSortModel();
obj.refresh();
}
just replace :
myGrid.refresh();
with this:
myGrid.getRowsTemplate().refresh();
Not sure if it only works on xpah xml's and table.setXML(wholeXML) , but worth to try, also as mentioned in the above post check that your new xml data is valid.
HTH
Carlos
Wednesday, June 24, 2009
where do i put that...
Thursday, June 25, 2009
this is my main function to create a grid, where do i put that code in so when i run this code again, it gets the latest xml file i just created?
function createxmlgridofteacherhomefolder(teacherid)
{
document.getElementById('Roster_Details_File_Distribution').innerHTML = "";
var table = new AW.XML.Table;
var d = new Date();
table.setURL("/data/"+teacherid+"_homefiles.xml?"+d.getTime());
table.request();
var columns = ["FileName"];
var obj = new AW.UI.Grid;
// write grid html to the page
document.getElementById('Roster_Details_File_Distribution').innerHTML = "<input type=hidden id=hidden_selected_rows_teacher_portal_files>" + obj;
}
Friday, June 26, 2009
anyone?
Friday, June 26, 2009
Try this one,
just need to call your function with a second parameter (firstTime)
[ true in the initial page-load (last line of code)]
and false when your link recreates the xml file..
Maybe you need some more delay (timeout) while recording the file at server side 2000= 2 seconds , so adjust it to your needs. window.setTimeout(function()
createxmlgridofteacherhomefolder("2", false);
},2000); Hope it makes more sense now.
function createxmlgridofteacherhomefolder(teacherid, firstTime)
{
//document.getElementById('Roster_Details_File_Distribution').innerHTML = "";
var table = new AW.XML.Table;
var d = new Date();
//table.setURL("/data/"+teacherid+"_homefiles.xml?"+d.getTime());
//table.request();
var columns = ["FileName"];
var obj = new AW.UI.Grid;
obj.setId("myGrid5");
obj.onSelectedRowsChanged = function(rowIndicesArray){
document.getElementById('hidden_selected_rows_teacher_portal_files').value = "" // Clear Current Value
for (i=0;i<rowIndicesArray.length;i++) {
// alert(obj.getCellValue(0,rowIndicesArray[i]))
var oldvalue = document.getElementById('hidden_selected_rows_teacher_portal_files').value;
document.getElementById('hidden_selected_rows_teacher_portal_files').value = oldvalue + "3$3" + obj.getCellValue(0,rowIndicesArray[i]);
}
}
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
Or try this one (much simpler) based on a single argument, that if passed empty then an empty grid will be painted.( without url xml error)
createxmlgridofteacherhomefolder("")
Note: no more need of cealr...Models , because every time you call this function a new table and grid are created.
HTH
function createxmlgridofteacherhomefolder(teacherid){
var obj = new AW.UI.Grid;
obj.setId("myGrid5");
obj.setHeaderText(columns);
obj.setColumnCount(1);
obj.setSelectorVisible(true);
obj.setSelectorText(function(i){return this.getRowPosition(i)});
obj.setSelectorWidth(25);
obj.setSelectionMode("multi-row");
obj.setRowCount(0);
if(teacherid != ""){
var columns = ["FileName"];
var table = new AW.XML.Table;
var d = new Date();
table.setURL("basic" + teacherid + ".xml" + "?" + d.getTime());
table.request();
var str = new AW.Formats.String;
var num = new AW.Formats.Number;
obj.setCellFormat([str]);
obj.setCellModel(table);
Ive tried them all, adding a random value to end of URL, doing all that clear crap, and nothing seems to work anyone?
Thursday, August 13, 2009
joe,
I'm posting the complete sample I used for testing this, which is almost the same of my last post.
(just need two files placed on same folder as page 'basic1.xml' and 'basic2.xml')
Perhaps is just a timing issue at your server, so, try some timeout before table.request() and after obj.setRowCount(table.getCount());
Note: I put a button to check it instead of a link, but shouldn't be any difference.
The only thing I corrected is placing the table and grid creation outside the function ( could be so?)
HTH
<script>
var button = new AW.UI.Button;
button.setControlText('load next xml file')
button.setId('a01');
button.onControlClicked = function(){
/// HERE YOU DO THE XML FILE REPLACE AT THE SERVER (link)
createxmlgridofteacherhomefolder("2", false);
alert(oldvalue)
var table = new AW.XML.Table;
var d = new Date();
var columns = ["FileName"];
var obj = new AW.UI.Grid;
obj.setId("myGrid5");
Where do i put my wait?
Do i do a javascript wait?
Thursday, August 13, 2009
I have this setup like this
build_graph()
{
}
create_xml_file()
{
//Do work
Then I call build_graph() after i built the xml file.
}
Thursday, August 13, 2009
I am recreating the xml file again, i am not hooking to another xml file.
so your example is not like mine..
I first load the xml file i built, then i have it if they make a change, it will rebuild the xml file, and then redisplay the updated graph. i see that the xml file has updated, but the graph is the same as the old one.
Thursday, August 13, 2009
Well I created it this way to simulate a change in rows and/or columns, but it really doesn't matter if is another file.
(i.e. if change to "1" the code below, you can load the page in the browser , then alter the xml file ,and finally [ in browser] select a row- push the button) this should have same effect as your server code.
-check that you can see the altered data.
Note: there is a missing '}' in my last post sample.
button.onControlClicked = function(){
/// HERE YOU DO THE XML FILE REPLACE AT THE SERVER (link)
createxmlgridofteacherhomefolder("2", false); //change to "1" for above sample
//alert(oldvalue)
} //MISSING
var table = new AW.XML.Table;
var d = new........
I would put a timeout delay here:
obj.setCellFormat([str]);
window.setTimeout(function(){ //START TIMEOUT
obj.setCellModel(table);
obj.setRowCount(table.getCount());
obj.refresh();
},3000);// END 3 SCONDS TIMEOUT
//.....
Sorry no other idea of what could be, but check also :
-disable broser/server cache
-utf-8 encoding