I have a grid with a column that shows whether a file has been downloaded or not (via an image in a grid column)
When the user clicks the Checkout toolbar button, I call an .ashx file, which downloads the file to the user's desktop and updates the the database that the file's been checked out. The issue I'm having is that when I try and refresh the grid by calling the grid.rebind method (on either the client or server side), not all the logic in the .ashx file gets executed (well, the database is updated, but the file isn't downloaded).
How can I refresh the grid on the client side after *successfully* calling the ashx method (where successfully means the file is downloaded *and* the database is updated)?
Here's the relevant code:
I have a client-side call that rebinds the grid (below) successfully from other methods, but when I call that after calling the CheckOut function, the file isn't saved locally (even though the grid rebinds).
When the user clicks the Checkout toolbar button, I call an .ashx file, which downloads the file to the user's desktop and updates the the database that the file's been checked out. The issue I'm having is that when I try and refresh the grid by calling the grid.rebind method (on either the client or server side), not all the logic in the .ashx file gets executed (well, the database is updated, but the file isn't downloaded).
How can I refresh the grid on the client side after *successfully* calling the ashx method (where successfully means the file is downloaded *and* the database is updated)?
Here's the relevant code:
function
CheckOut(){
var
isExternal =
false
;
var
rgGrid = $find(
"<%= rgAttachmentVersion.ClientID %>"
);
if
( rgGrid._selectedIndexes[0] ==
null
) {
rgGrid = $find(
"<%= rgExternalAttachment.ClientID %>"
);
isExternal =
true
;
}
var
selectedVersionId;
if
( isExternal ) {
selectedVersionId = rgGrid._clientKeyValues[rgGrid._selectedIndexes[0]].ID +
"&isExternal=true"
;
}
else
if
( rgGrid._selectedIndexes[0].indexOf(
":"
) > 0 ) {
selectedVersionId = rgGrid._clientKeyValues[rgGrid._selectedIndexes[0]].ID;
}
else
{
selectedVersionId = rgGrid.MasterTableView.getCellByColumnUniqueName(rgGrid.MasterTableView.get_dataItems()[rgGrid._selectedIndexes[0]],
"OpenVersion"
).innerHTML;
}
var
finalUrl =
"~/VersionCheckoutHandler.ashx?id="
+ selectedVersionId +
"&callback=false"
+
"&rand="
+ Math.random();
// add random number to make sure the browser does nto cache it
var
xhReq =
new
XMLHttpRequest();
xhReq.open(
"GET"
,$Url.resolve(finalUrl),
false
);
xhReq.send(
null
);
if
( xhReq.responseText ==
"FILEDOWNLOADERROR"
)
{
alert(
"An error has occurred. Please contact your system administrator."
);
}
else
if
( xhReq.responseText ==
"VERSIONALREADYCHECKEDOUT"
)
{
alert(
"This version is currently checked out."
);
refreshAttachmentList();
}
else
if
( xhReq.responseText ==
"UNABLETOCHECKOUTREMOTEREPOSITORY"
)
{
alert(
"This version is unable to be checked out from the remote repository."
);
}
else
{
triggerIsPostBack =
true
;
window.location = $Url.resolve(
"~/VersionCheckoutHandler.ashx?id="
+ selectedVersionId +
"&callback=true"
);
triggerIsPostBack =
false
;
}
}
I have a client-side call that rebinds the grid (below) successfully from other methods, but when I call that after calling the CheckOut function, the file isn't saved locally (even though the grid rebinds).
function
refreshAttachmentList() {
try
{displayLogoffWarning =
false
;}
catch
(ex) {}
try
{
$find(
"<%= rgAttachmentVersion.MasterTableView.ClientID %>"
).fireCommand(
'<%=RadGrid.RebindGridCommandName %>'
);
}
catch
(ex) { }
try
{
$find(
"<%= rgExternalAttachment.MasterTableView.ClientID %>"
).fireCommand(
'<%=RadGrid.RebindGridCommandName %>'
);
}
catch
(ex) { }
}