功能描述:行政区域国家、省、市、区四级联动
实现步骤:
1、创建行政区域实体,用来记录行政区域信息,如下图: 
9-3-01.JPG

2、打开行政区域实体查找视图,增加查找列"上级区域id",如下图:
9-3-02.JPG
3、在上级区域属性的onchange事件中加入以下js代码:
var lookupItem = new Array;
lookupItem 
= crmForm.all.new_parentregion.DataValue;
if (IsNull(lookupItem) == false)
{
       crmForm.all.new_parentregionid.DataValue 
= lookupItem[0].id;
}
else
{
       crmForm.all.new_parentregionid.DataValue 
= "{00000000-0000-0000-0000-000000000000}";
}

4、客户跟行政区域之间创建4个1:N的关系,分别为国家、省、市、区,如下图:
9-3-03.JPG
5、在客户的onload事件中加入以下js代码:
crmForm.all.new_country.additionalparams =  'search=' + encodeURIComponent("{9C534EEA-FC73-DD11-A8D3-001676D4971B}");
var lookupItem = new Array;
lookupItem 
= crmForm.all.new_country.DataValue;
if (IsNull(lookupItem) == false)
{
       
var id = lookupItem[0].id;
       crmForm.all.new_province.additionalparams 
=  'search=' + encodeURIComponent(id);
}
else
{
       crmForm.all.new_province.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
}

lookupItem 
= crmForm.all.new_province.DataValue;
if (IsNull(lookupItem) == false)
{
       
var id = lookupItem[0].id;
       crmForm.all.new_city.additionalparams 
=  'search=' + encodeURIComponent(id);
}
else
{
       crmForm.all.new_city.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");

}

lookupItem 
= crmForm.all.new_city.DataValue;
if (IsNull(lookupItem) == false)
{
       
var id = lookupItem[0].id;
       crmForm.all.new_area.additionalparams 
=  'search=' + encodeURIComponent(id);
}
else
{
       crmForm.all.new_area.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
}

6、分别在国家、省、市三个属性的onchange事件中加入以下js代码:
//国家属性
var lookupItem = new Array;
lookupItem 
= crmForm.all.new_country.DataValue;
if (IsNull(lookupItem) == false)
{
       
var id = lookupItem[0].id;
       crmForm.all.new_province.additionalparams 
=  'search=' + encodeURIComponent(id);
}
else
{
       crmForm.all.new_province.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
}
crmForm.all.new_city.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
crmForm.all.new_area.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
crmForm.all.new_province.DataValue 
= null;
crmForm.all.new_city.DataValue 
= null;
crmForm.all.new_area.DataValue 
= null;
//省属性
var lookupItem = new Array;
lookupItem 
= crmForm.all.new_province.DataValue;
if (IsNull(lookupItem) == false)
{
       
var id = lookupItem[0].id;
       crmForm.all.new_city.additionalparams 
=  'search=' + encodeURIComponent(id);
}
else
{
       crmForm.all.new_city.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
}
crmForm.all.new_area.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
crmForm.all.new_city.DataValue 
= null;
crmForm.all.new_area.DataValue 
= null;
//市属性
var lookupItem = new Array;
lookupItem 
= crmForm.all.new_city.DataValue;
if (IsNull(lookupItem) == false)
{
       
var id = lookupItem[0].id;
       crmForm.all.new_area.additionalparams 
=  'search=' + encodeURIComponent(id);
}
else
{
       crmForm.all.new_area.additionalparams 
=  'search=' + encodeURIComponent("{00000000-0000-0000-0000-000000000000}");
}
crmForm.all.new_area.DataValue 
= null;

效果如下:

9-3-04.JPG

9-3-05.JPG

9-3-06.JPG

9-3-07.JPG

9-3-08.JPG

9-3-09.JPG

posted on 2008-09-03 23:17  Batistuta Cai  阅读(2379)  评论(16编辑  收藏  举报