Form _OnLoad
var _oArea;
fetchObj=new Object();
fetchObj.loadUserDefinedArea=_loadUserDefinedArea;
fetchObj.ExecuteQuery=_ExecuteQuery;
fetchObj.myalert=_myalert;
fetchObj.getFetchXml=_getFetchXml;
fetchObj.getLayoutXml=_getLayoutXml;
leftNavRename ('WriteInProducts','ProductPriceLevel','Write-In Products','Product Price Level');
Code
2.aspx<%@ page language="C#" autoeventwireup="true" inherits="Var_AdvFetch, App_Web_var_advfetch.aspx.cdcab7d2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>AdvanceFind</title>
<script type="text/javascript" src="/_static/_controls/util/util.js"></script>
<script type="text/javascript" src="/_static/_common/scripts/global.js"></script>
<script type="text/javascript" src="/_static/_common/scripts/xmlutil.js"></script>
<script type="text/javascript" src="/_static/_controls/remotecommands/remotecommand.js"></script>
<script type="text/javascript" src="/_common/windowinformation/windowinformation.aspx"></script>
<script type="text/javascript" src="/_static/_common/scripts/stage.js"></script>
<script type="text/javascript" src="/_static/_common/scripts/select.js"></script>
<script type="text/javascript" src="/_static/_controls/lookup/lookup.js"></script>
<script type="text/javascript" src="/_static/_controls/datetime/time.js"></script>
<script type="text/javascript" src="/_static/_controls/number/number.js"></script>
<script type="text/javascript" language ="javascript" >
/*
*函數功能:從href獲得參數
*韓建興
*sHref: http://www.var.com.tw/arg.htm?arg1=d&arg2=re
*sArgName:arg1, arg2
*return: the value of arg. d, re
*/
function GetArgsFromHref(sHref, sArgName)
{
var args = sHref.split("?");
var retval = "";
if(args[0] == sHref) /*參數爲空*/
{
return retval; /*無需做任何處理*/
}
var str = args[1];
args = str.split("&");
for(var i = 0; i < args.length; i ++)
{
str = args[i];
var arg = str.split("=");
if(arg.length <= 1) continue;
if(arg[0] == sArgName) retval = arg[1];
}
return retval;
}
function GetArgs(sArgName)
{
var args = window.location.split("?");
var retval = "";
if(args[0] == window.location) /*參數爲空*/
{
return retval; /*無需做任何處理*/
}
var str = args[1];
args = str.split("&");
for(var i = 0; i < args.length; i ++)
{
str = args[i];
var arg = str.split("=");
if(arg.length <= 1) continue;
if(arg[0] == sArgName) retval = arg[1];
}
return retval;
}
function ExecuteQuery()
{
//resultRender.FetchXml.value = GetArgs ("FetchXml");
//resultRender.LayoutXml.value = GetArgs ("LayoutXml");
//resultRender.EntityName.value = GetArgs ("EntityName");
resultFrame.document.body.innerHTML = "<table height='100%' width='100%' style='cursor:wait'><tr><td valign='middle' align='center'><img alt='' src='_imgs/AdvFind/progress.gif'/><br></td></tr></table>";
window.setTimeout("resultRender.submit()", 10);
//target="resultFrame"
}
function onresultFrameReady()
{
var i=0;
if( event.srcElement.readyState == "complete" && resultFrame.document.body.all["crmGrid"])
{
//afterresultRefresh();
var resultcrmGrid=resultFrame.document.body.all["crmGrid"];
debug.innerText =resultcrmGrid.gridXml;
//resultcrmGrid.onrefresh=function()
//{
// afterresultRefresh();
//}
//resultFrame.document.selectSingleNode("");
}
}
function afterresultRefresh()
{
var document1=loadXmlDocument(resultRender.LayoutXml.value);
var resultcrmGrid=resultFrame.document.body.all["crmGrid"];
var oCells=document1.selectNodes("//cell");
if (oCells!=null)
{
iLen = oCells.length;
for (i = 0; i < iLen; i++)
{
var odisplayName=oCells[i].getAttribute ("displayName");
if (odisplayName!=null)
{
var oName=oCells[i].getAttribute ("name");
var oGridCol=findColumn(oName);
if (oGridCol!=null)
{
// oGridCol.innerText=odisplayName;
}
}
}
}
var oPrimaryCol=findColumn("productpricelevel.productpricelevelid");
oPrimaryCol.display="none";
debug.innerText =resultcrmGrid.gridXml;
var ogridbodyTable=resultcrmGrid.all["gridBodyTable"];
//ogridbodyTable.oname="1026";
var oRows=resultcrmGrid.all["gridBodyTable"].rows;
var iLen=oRows.length;
i=0;
//objecttypecode="1026";
while (i<iLen)
{
//oRows[i].otype="1026";
//oRows[i].oid=oRows[i]["productpricelevel.productpricelevelid"];
//alert(oRows[i].getAttribute ("productpricelevel.productpricelevelid").value);
i++;
}
//resultcrmGrid.SetParameter("otc","1026");
}
function findColumn(sName)
{
var i = 0;
var oCells = resultFrame.document.body.all["crmGrid"].all["gridBar"].rows[0].cells;
var iLen = oCells.length;
while (i < iLen)
{
if (oCells[i].field && oCells[i].field == sName)
{
return oCells[i];
}
i++;
}
return null;
}
//document.frames("resultFrame").onreadystatechange = onresultFrameReady;
//target="resultFrame"
</script>
</head>
<body>
<FORM id="resultRender" action="/AdvancedFind/fetchData.aspx" method="post" target="resultFrame" >
<INPUT type="button" name="btnOK" value="OK" id ="btnOK" onclick="ExecuteQuery()">
<INPUT type="input" name=FetchXml value ="<fetch mapping='logical'> <entity name='pricelevel'> <attribute name='name'/> <filter type='and'> <condition attribute='pricelevelid' operator='in'> <value>9439FF4D-8613-DE11-B063-001EC9B6EAFD</value> <value>34D7F7A6-6F56-DE11-B691-002215572EEF</value> </condition> </filter> <link-entity name='productpricelevel' from='pricelevelid' to='pricelevelid' alias='productpricelevel' link-type='inner'> <attribute name='productpricelevelid'/> <link-entity name='uom' from='uomid' to='uomid' alias='uom' link-type='natural'> <attribute name='name'/> </link-entity> <link-entity name='product' from='productid' to='productid' alias='product' link-type='natural'> <attribute name='name'/> <attribute name='productnumber'/> </link-entity> </link-entity> </entity></fetch>">
<INPUT type="input" name=LayoutXml value='<grid name="resultset" object="1022" select="1" icon="1" preview="0"><row name="result" id="productpricelevel.productpricelevelid"><cell name="productpricelevel.productpricelevelid" ishidden="1"/><cell name="name" displayName="Name(PriceLevel)" width="150"/><cell name="product.name" displayName="Product Name" width="300" disableSorting="1"/><cell name="product.productnumber" displayName="EV_P/N" width="200" disableSorting="1"/><cell name="uom.name" displayName="Unit" width="100"/><cell name="statecode" width="100"/></row></grid>'>
<!-- <INPUT type ="hidden" name="FetchXml" value="<fetch mapping='logical'> <entity name='productpricelevel'><attribute name='pricelevelid'/> <attribute name='productpricelevelid'/></entity></fetch>">
<INPUT type ="hidden" name="LayoutXml" value="<grid name='resultset' object='1026' select ='1' icon='1'><row name='result' id='productpricelevelid'><cell name='pricelevelid'/></row></grid>">
-->
<INPUT type="input" value="pricelevel" name="EntityName">
<INPUT type="input" value="{3A736265-B902-4D09-A08B-725F6C31916E}" name="DefaultAdvFindViewId">
<INPUT type="input" value="{2ca5dce5-1477-de11-8acb-002215572eef}" name="ViewId">
<INPUT type="input" value="1039" name="ViewType">
<INPUT type="hidden" value="false" name="SortDescend">
</FORM>
<div id="debug" style="display:inline;position:absolute;100%;height:50%"> </div>
<iframe id="resultFrame" name="resultFrame" style ="position:absolute;top:600px;100%;height:50%;border:0px" src="/_root/Blank.aspx" onreadystatechange="onresultFrameReady()" ></iframe>
</body>
</html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>AdvanceFind</title>
<script type="text/javascript" src="/_static/_controls/util/util.js"></script>
<script type="text/javascript" src="/_static/_common/scripts/global.js"></script>
<script type="text/javascript" src="/_static/_common/scripts/xmlutil.js"></script>
<script type="text/javascript" src="/_static/_controls/remotecommands/remotecommand.js"></script>
<script type="text/javascript" src="/_common/windowinformation/windowinformation.aspx"></script>
<script type="text/javascript" src="/_static/_common/scripts/stage.js"></script>
<script type="text/javascript" src="/_static/_common/scripts/select.js"></script>
<script type="text/javascript" src="/_static/_controls/lookup/lookup.js"></script>
<script type="text/javascript" src="/_static/_controls/datetime/time.js"></script>
<script type="text/javascript" src="/_static/_controls/number/number.js"></script>
<script type="text/javascript" language ="javascript" >
/*
*函數功能:從href獲得參數
*韓建興
*sHref: http://www.var.com.tw/arg.htm?arg1=d&arg2=re
*sArgName:arg1, arg2
*return: the value of arg. d, re
*/
function GetArgsFromHref(sHref, sArgName)
{
var args = sHref.split("?");
var retval = "";
if(args[0] == sHref) /*參數爲空*/
{
return retval; /*無需做任何處理*/
}
var str = args[1];
args = str.split("&");
for(var i = 0; i < args.length; i ++)
{
str = args[i];
var arg = str.split("=");
if(arg.length <= 1) continue;
if(arg[0] == sArgName) retval = arg[1];
}
return retval;
}
function GetArgs(sArgName)
{
var args = window.location.split("?");
var retval = "";
if(args[0] == window.location) /*參數爲空*/
{
return retval; /*無需做任何處理*/
}
var str = args[1];
args = str.split("&");
for(var i = 0; i < args.length; i ++)
{
str = args[i];
var arg = str.split("=");
if(arg.length <= 1) continue;
if(arg[0] == sArgName) retval = arg[1];
}
return retval;
}
function ExecuteQuery()
{
//resultRender.FetchXml.value = GetArgs ("FetchXml");
//resultRender.LayoutXml.value = GetArgs ("LayoutXml");
//resultRender.EntityName.value = GetArgs ("EntityName");
resultFrame.document.body.innerHTML = "<table height='100%' width='100%' style='cursor:wait'><tr><td valign='middle' align='center'><img alt='' src='_imgs/AdvFind/progress.gif'/><br></td></tr></table>";
window.setTimeout("resultRender.submit()", 10);
//target="resultFrame"
}
function onresultFrameReady()
{
var i=0;
if( event.srcElement.readyState == "complete" && resultFrame.document.body.all["crmGrid"])
{
//afterresultRefresh();
var resultcrmGrid=resultFrame.document.body.all["crmGrid"];
debug.innerText =resultcrmGrid.gridXml;
//resultcrmGrid.onrefresh=function()
//{
// afterresultRefresh();
//}
//resultFrame.document.selectSingleNode("");
}
}
function afterresultRefresh()
{
var document1=loadXmlDocument(resultRender.LayoutXml.value);
var resultcrmGrid=resultFrame.document.body.all["crmGrid"];
var oCells=document1.selectNodes("//cell");
if (oCells!=null)
{
iLen = oCells.length;
for (i = 0; i < iLen; i++)
{
var odisplayName=oCells[i].getAttribute ("displayName");
if (odisplayName!=null)
{
var oName=oCells[i].getAttribute ("name");
var oGridCol=findColumn(oName);
if (oGridCol!=null)
{
// oGridCol.innerText=odisplayName;
}
}
}
}
var oPrimaryCol=findColumn("productpricelevel.productpricelevelid");
oPrimaryCol.display="none";
debug.innerText =resultcrmGrid.gridXml;
var ogridbodyTable=resultcrmGrid.all["gridBodyTable"];
//ogridbodyTable.oname="1026";
var oRows=resultcrmGrid.all["gridBodyTable"].rows;
var iLen=oRows.length;
i=0;
//objecttypecode="1026";
while (i<iLen)
{
//oRows[i].otype="1026";
//oRows[i].oid=oRows[i]["productpricelevel.productpricelevelid"];
//alert(oRows[i].getAttribute ("productpricelevel.productpricelevelid").value);
i++;
}
//resultcrmGrid.SetParameter("otc","1026");
}
function findColumn(sName)
{
var i = 0;
var oCells = resultFrame.document.body.all["crmGrid"].all["gridBar"].rows[0].cells;
var iLen = oCells.length;
while (i < iLen)
{
if (oCells[i].field && oCells[i].field == sName)
{
return oCells[i];
}
i++;
}
return null;
}
//document.frames("resultFrame").onreadystatechange = onresultFrameReady;
//target="resultFrame"
</script>
</head>
<body>
<FORM id="resultRender" action="/AdvancedFind/fetchData.aspx" method="post" target="resultFrame" >
<INPUT type="button" name="btnOK" value="OK" id ="btnOK" onclick="ExecuteQuery()">
<INPUT type="input" name=FetchXml value ="<fetch mapping='logical'> <entity name='pricelevel'> <attribute name='name'/> <filter type='and'> <condition attribute='pricelevelid' operator='in'> <value>9439FF4D-8613-DE11-B063-001EC9B6EAFD</value> <value>34D7F7A6-6F56-DE11-B691-002215572EEF</value> </condition> </filter> <link-entity name='productpricelevel' from='pricelevelid' to='pricelevelid' alias='productpricelevel' link-type='inner'> <attribute name='productpricelevelid'/> <link-entity name='uom' from='uomid' to='uomid' alias='uom' link-type='natural'> <attribute name='name'/> </link-entity> <link-entity name='product' from='productid' to='productid' alias='product' link-type='natural'> <attribute name='name'/> <attribute name='productnumber'/> </link-entity> </link-entity> </entity></fetch>">
<INPUT type="input" name=LayoutXml value='<grid name="resultset" object="1022" select="1" icon="1" preview="0"><row name="result" id="productpricelevel.productpricelevelid"><cell name="productpricelevel.productpricelevelid" ishidden="1"/><cell name="name" displayName="Name(PriceLevel)" width="150"/><cell name="product.name" displayName="Product Name" width="300" disableSorting="1"/><cell name="product.productnumber" displayName="EV_P/N" width="200" disableSorting="1"/><cell name="uom.name" displayName="Unit" width="100"/><cell name="statecode" width="100"/></row></grid>'>
<!-- <INPUT type ="hidden" name="FetchXml" value="<fetch mapping='logical'> <entity name='productpricelevel'><attribute name='pricelevelid'/> <attribute name='productpricelevelid'/></entity></fetch>">
<INPUT type ="hidden" name="LayoutXml" value="<grid name='resultset' object='1026' select ='1' icon='1'><row name='result' id='productpricelevelid'><cell name='pricelevelid'/></row></grid>">
-->
<INPUT type="input" value="pricelevel" name="EntityName">
<INPUT type="input" value="{3A736265-B902-4D09-A08B-725F6C31916E}" name="DefaultAdvFindViewId">
<INPUT type="input" value="{2ca5dce5-1477-de11-8acb-002215572eef}" name="ViewId">
<INPUT type="input" value="1039" name="ViewType">
<INPUT type="hidden" value="false" name="SortDescend">
</FORM>
<div id="debug" style="display:inline;position:absolute;100%;height:50%"> </div>
<iframe id="resultFrame" name="resultFrame" style ="position:absolute;top:600px;100%;height:50%;border:0px" src="/_root/Blank.aspx" onreadystatechange="onresultFrameReady()" ></iframe>
</body>
</html