Saturday, January 9, 2010

Adding Loading indicator after using a custome tool from the toolbar that interacts with a Map control

Very often i see forum posts asking how to initiate a loading indicator or something to tell the user that this tool is doing something, please wait.. in 9.2 we had the choice to edit javascript of ADF controls, but in 9.3 its not supported anymore, all you can do is override javascript function, i have not really experience with that but i have got a quick fix for this.. the implementation is below..



server action of custom tool

 

adfMap = (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)toolEventArgs.Control;

ESRI.ArcGIS.ADF.Web.UI.WebControls.MapPointEventArgs mapPointEventArgs =

(ESRI.ArcGIS.ADF.Web.UI.WebControls.MapPointEventArgs)toolEventArgs;

            ESRI.ArcGIS.ADF.Web.Geometry.Point adfPoint = mapPointEventArgs.MapPoint;

string JS = "GetSocumentList(" + adfPoint.X + "," + adfPoint.Y +");";

//call a javascript function in the default.aspx

adfMap.CallbackResults.Add(new ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(null, null, "javascript", JS));

 

 

//the javascript function in default.aspx is, we are setting a panel visibility that has an animated gid in it

function GetSocumentList(pointXCoor,PointYCoor)

{

    expandConsolePanel('RigsDoc_Panel');

    document.getElementById('DIVLoadingPanel').style.visibility = 'visible';

    var message = 'GetRigsDocumentList';

    message += "," + pointXCoor + "," + PointYCoor;

    var context = 'Map';

    <%=sCallBackFunctionInvocation%>

}

 

//after we initiate the callback and we get back the finish processing we set the visibility of the div and display the results

 

private string GetDocumentsList(string RigName)

{

    //some time consuming process

    Map1.CallbackResults.Add(new  ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult(null, null, "javascript", "var newHTML ='" + x + "'; document.getElementById('lstDocs').innerHTML=newHTML;document.getElementById('DIVLoadingPanel').style.visibility = 'hidden'"));

    returnstring = Map1.CallbackResults.ToString();

}

No comments: