AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 21.03.2009, 06:43   #1  
Blog bot is offline
Blog bot
Участник
 
25,584 / 848 (80) +++++++
Регистрация: 28.10.2006
mscrm4ever: Creating a Network Path Text Control
Источник: http://mscrm4ever.blogspot.com/2009/...t-control.html
==============






Dynamics supports several types of text fields. One type which is not available in the current version is a text field that supports a UNC path (\\) or a network drive (Y:) to a shared folder on the server or on the user local machine.


The following example converts a regular text field into a network path control. The control works in conjunction with an Explorer page which contains an IFRAME to the actual network share.


The Explorer(.aspx) should be deployed in the ISV folder. When the user double clicks on the field value a window is opened pointing to the shared folder. The control also provides a comfortable API for managing extra query parameters, changing control style, changing explorer window features and setting an initial network path. The last can be a handy feature if you require the explorer to point to an account personal folder within a shared file system tree.


Here is the Explorer.aspx implementation:







Dynamics File Explorer

.header
{
background-color:#639ace;
padding-left:10px;
color:White;
font-size:x-large;
font-family:arial;
height:30px;
}

.iframe
{
border:1px solid #94b2de;
height:100%;
width:100%;
}

body
{
margin:0px;
border:0px solid;
}





File Explorer












The following script should be added to the entity onload event:



// JScript File
function OnCrmPageLoad()
{
var networkPath = new NetworkPath("fax");
//Example Add query string parameter
networkPath.Params.Add("test","1");
//Example Remove query string parameter
networkPath.Params.Remove("test");
//Example change control default style
networkPath.Style.Add("color","red");
//Transform the text field into a network path field
networkPath.Transform();
}

function NetworkPath(baseControlId)
{
nk = this;
nk.ID = baseControlId;
nk.Control = document.all[nk.ID];
/* Default Path */
nk.Path = "\\\\127.0.0.1\\Files"; //default path
nk.Window = null;
/* File Explorer Features (window.open)*/
nk.Features = new Dictionary(",","=");
/* If you wish to extend the Explorer.aspx and add more querystring parameters */
nk.Params = new Dictionary("&","=");
/* Network path control additional styling rules */
nk.Style = new Dictionary(";",":");

nk.Transform = function()
{
if (nk.Control)
{
/* Assign default path if control value is empty */
if (nk.Control.DataValue == null)
{
nk.Control.DataValue = nk.Path;
}

nk.Control.title = "Double Click to Open Network Explorer";
/* Default Window Settings */
if (!nk.Features.Exist("width"))
{
nk.Features.Add("width",700);
}
if (!nk.Features.Exist("height"))
{
nk.Features.Add("height",400);
}
if (!nk.Features.Exist("resize"))
{
nk.Features.Add("resize","yes");
}
if (!nk.Features.Exist("toolbar"))
{
nk.Features.Add("toolbar","no");
}
if (!nk.Features.Exist("menubar"))
{
nk.Features.Add("menubar","no");
}
if (!nk.Features.Exist("titlebar"))
{
nk.Features.Add("titlebar","no");
}
/* Attach validation to change and save events */
nk.Control.attachEvent( "onchange" , nk.Validate );
crmForm.attachEvent( "onsave" , nk.Validate );

/* Adjust control style */
nk.Style.Add("text-decoration","underline");
if (!nk.Style.Exist("color"))
{
nk.Style.Add("color","blue");
}
nk.Style.Add("cursor","hand");
nk.Control.style.cssText += ";" + nk.Style.ToString();

/* Add double click functionality */
nk.Control.ondblclick = nk.Open;
}
}

nk.Validate = function()
{
if (nk.Control.DataValue == null)
{
return true;
}

/* validate \\ unc path or a netwrok drive Y: */
var regex = new RegExp("^(\\\\|[a-zA-Z]:)");
if (!regex.exec(nk.Control.DataValue))
{
alert("Invalid Network Path or Drive");
return (event.returnValue = false);
}

return true;
}

nk.Open = function()
{
if (nk.Control.DataValue != null)
{
nk.Window = window.open( SERVER_URL + "/isv/explorer.aspx?path=" + nk.Control.DataValue + nk.Params.ToString() , "" , nk.Features.ToString());
}
}

nk.Close = function()
{
nk.Window.close();
}

/* Key Value Pair Collection */
function Dictionary(sep,delim)
{
this.list = [];
this.Seperator = sep;
this.Delimiter = delim

this.Add = function(key , value)
{
this.list[key] = value;
}

this.Remove = function(key)
{
this.list[key] = "";
}

this.Exist = function(key)
{
return this.list[key] != null && this.list[key] != "";
}

this.ToString = function()
{
var result = new StringBuilder();
result.Append(this.Seperator);
for(var key in this.list)
{
if (this.list[key]!="")
{
result.Append(key).Append(this.Delimiter);
result.Append(this.list[key]).Append(this.Seperator);
}
}
var tmp = result.ToString();
return tmp.substring(0,tmp.length-1);
}
}

function StringBuilder()
{
this.data = [];

this.Append = function(text)
{
this.data[this.data.length] = text;
return this;
}

this.Reset = function()
{
this.data = [];
}

this.ToString = function()
{
return this.data.join("");
}
}
}

OnCrmPageLoad();



Источник: http://mscrm4ever.blogspot.com/2009/...t-control.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
mscrm4ever: Displaying an Image in an IFRAME Blog bot Dynamics CRM: Blogs 0 10.02.2009 21:06
mscrm4ever: CRM 4.0 Creating Interactive Plug-ins Blog bot Dynamics CRM: Blogs 0 21.01.2009 10:05
mscrm4ever: CRM 4.0 State and Status code Manager Wizard Blog bot Dynamics CRM: Blogs 0 19.01.2009 02:07
mscrm4ever: CRM 4.0 Tooltip Wizard Blog bot Dynamics CRM: Blogs 0 25.12.2008 15:05
mscrm4ever: CRM 4.0 Supported Multi Select (Picklist) Control Blog bot Dynamics CRM: Blogs 0 25.12.2008 15:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 21:41.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.