http://www.crossbrowser.net/82/internet-explorer-box-model-is-not-a-bug/
Internet Explorer box model bug
Posted by
bitmax
at
16:42
http://www.crossbrowser.net/82/internet-explorer-box-model-is-not-a-bug/
0
comments
Labels:
css
JavaScript Timers with setTimeout and setInterval
Posted by
bitmax
at
16:40
In this tutorial we'll look at JavaScript's setTimeout(), clearTimeout(), setInterval() and clearInterval() methods, and show how to use them to set timers and create delayed actions.
http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/
0
comments
Labels:
javascript
SharePoint WebPart Property Attributes
Posted by
bitmax
at
10:01
WebBrowsable [WebBrowsable(True)]"Indicates whether the designated property of a Web Parts control is displayed in a PropertyGridEditorPart object." (MSDN)
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webbrowsableattribute.aspx
WebPartStorage [WebPartStorage(Storage.Personal)]This attribute specifies what type of storage options the WebPart will make use of. The most common is Storage.Personal. "This property can be personalized by individual users. Its WebPartStorageAttribute value is Storage.Personal, which specifies that the property can be stored on a per-user basis. Only users with the Personalize Web Part pages right can set this property." (MSDN)
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpartstorageattribute.aspx
Personalizable [Personalizable(true)]Allows users the ability to personalize settings for the WebPart.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.personalizableattribute.aspx
WebDispayName [WebDisplayName(string)]Defines the Friendly Name for a property of a WebPart control. This is the name that will show up in the editor screen.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webdisplaynameattribute.aspx
WebDescription [WebDescription(string)]Defines the string value to use as a ToolTip for a property of a Web Parts control. (MSDN)
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webdescriptionattribute.aspx
SPWebCategoryName [SPWebCategoryName(string)]Defines the friendly or localized name of the category of a property in the CustomPropertyToolPartcontrol inside the ToolPane.
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.spwebcategorynameattribute.aspx
ConnectionProvider [ConnectionProvider(string)] Identifies the callback method in a server control acting as the provider in a Web Parts connection, and enables developers to specify details about the provider's connection point. (MSDN) This is used to create connectable WebParts.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.connectionproviderattribute.aspx
ConnectionConsumer [ConnectionConsumer(string)]Identifies the callback method in a server control acting as the consumer in a Web Parts connection, and enables developers to specify details about the consumer's connection point. (MSDN) This is used to create connectable WebParts.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.connectionconsumerattribute.aspx
Below is an example of how to use these attributes in your WebPart code.
[WebBrowsable(true),
Personalizable(false),
WebPartStorage(Storage.Personal),
WebDisplayName("User Name(Domain\\username)"),
WebDescription("User to display in the WebPart."),
SPWebCategoryName("Options")]
public string UserLoginName
{
get { return _loginName; }
set { _loginName = value; }
}
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webbrowsableattribute.aspx
WebPartStorage [WebPartStorage(Storage.Personal)]This attribute specifies what type of storage options the WebPart will make use of. The most common is Storage.Personal. "This property can be personalized by individual users. Its WebPartStorageAttribute value is Storage.Personal, which specifies that the property can be stored on a per-user basis. Only users with the Personalize Web Part pages right can set this property." (MSDN)
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.webpartstorageattribute.aspx
Personalizable [Personalizable(true)]Allows users the ability to personalize settings for the WebPart.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.personalizableattribute.aspx
WebDispayName [WebDisplayName(string)]Defines the Friendly Name for a property of a WebPart control. This is the name that will show up in the editor screen.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webdisplaynameattribute.aspx
WebDescription [WebDescription(string)]Defines the string value to use as a ToolTip for a property of a Web Parts control. (MSDN)
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.webdescriptionattribute.aspx
SPWebCategoryName [SPWebCategoryName(string)]Defines the friendly or localized name of the category of a property in the CustomPropertyToolPartcontrol inside the ToolPane.
http://msdn2.microsoft.com/en-us/library/microsoft.sharepoint.webpartpages.spwebcategorynameattribute.aspx
ConnectionProvider [ConnectionProvider(string)] Identifies the callback method in a server control acting as the provider in a Web Parts connection, and enables developers to specify details about the provider's connection point. (MSDN) This is used to create connectable WebParts.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.connectionproviderattribute.aspx
ConnectionConsumer [ConnectionConsumer(string)]Identifies the callback method in a server control acting as the consumer in a Web Parts connection, and enables developers to specify details about the consumer's connection point. (MSDN) This is used to create connectable WebParts.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.connectionconsumerattribute.aspx
Below is an example of how to use these attributes in your WebPart code.
[WebBrowsable(true),
Personalizable(false),
WebPartStorage(Storage.Personal),
WebDisplayName("User Name(Domain\\username)"),
WebDescription("User to display in the WebPart."),
SPWebCategoryName("Options")]
public string UserLoginName
{
get { return _loginName; }
set { _loginName = value; }
}
0
comments
Labels:
Sharepoint
Custom context menu trong SharePoint
Posted by
bitmax
at
16:31
Căn Bản
Đầu tiên là tạo một custom context đã, nó là gì bạn có thể xem hình bên dứơi:
Nếu muốn thêm thuộc tính trong Context menu thì làm sao ?
1. Add thêm webpart
2. Chọn Content Editor, lưu ý web part Content Editor phải nằm trước web part List, để chắc rằng script dc thực thi trước. xem thêm nguồn tham khảo bên dứơi:
3. View Source, copy đọan bên dưới:
function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = “Navigate to Google”;
var strAction = “STSNavigate(‘http://www.google.com’)”;
var strImagePath = “”;
CAMOpt(m, strDisplayText, strAction, strImagePath);
CAMSep(m);
return false;
}
5. Kết quả
Chú ý:
1. “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\" Hàm js sử dụng trong ví dụ trên nằm trong OWS.JS
2. Nếu là Document Library thì dùng hàm Custom_AddDocLibMenuItems, nếu là List thì dùng Custom_AddListMenuItems
Nguồn tham khảo: http://www.mstechblogs.com/shailaja/create-a-custom-context-menu-in-sharepoint-list-or-document-library/
Nâng cao
Nguồn đọc thêm: http://blogs.msdn.com/b/bowerm/archive/2004/07/07/175691.aspx
http://sharepointstudio.markstokes.com/2005/11/add-context-menu-send-document-link-by.html
http://stackoverflow.com/questions/745499/sharepoint-custom-context-menu-in-custom-list-appears-on-folders-and-not-just-fil
Nên đọc thêm 3 link trên. coi thêm các file js của sharepoint OWS.JS, CORE.JS, IMGLIB.JS ở thư mục C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033.
Bây giờ ta giải thix 1 chút về các hàm đã sử dụng là Custom_AddDocLibMenuItems hay Custom_AddDocLibMenuItems.
function Custom_AddDocLibMenuItems(m, ctx)
tham số m chưa có giá trị ban đầu, nó chỉ có sau khi chạy hàm này
CAMOpt(m, strDisplayText, strAction, strImagePath);
giá trị trả về là chính nội dung strDisplayText trong thẻ span. muốn biết thì alert(m.innerHTML)
Coi thông tin biến ctx, từ view source ta thấy:
ctx = new ContextInfo();
ctx.listBaseType = 1;
ctx.listTemplate = 109;
ctx.listName = "{9370E172-8760-4303-AE31-E9426126B6ED}";
ctx.view = "{FE7A0018-7358-4B70-972D-5799B43F095C}";
ctx.listUrlDir = "\u002fnews\u002fLists\u002fPhotos";
ctx.HttpPath = "\u002fnews\u002f_vti_bin\u002fowssvr.dll?CS=65001";
ctx.HttpRoot = "http:\u002f\u002fnqnguyen\u002fnews";
ctx.imagesPath = "\u002f_layouts\u002fimages\u002f";
ctx.PortalUrl = "";
ctx.SendToLocationName = "";
ctx.SendToLocationUrl = "";
ctx.RecycleBinEnabled = -1;
ctx.OfficialFileName = "";
ctx.WriteSecurity = "1";
ctx.SiteTitle = "Tin T\u1ee9c";
ctx.ListTitle = "Photos";
if (ctx.PortalUrl == "") ctx.PortalUrl = null;
ctx.displayFormUrl = "\u002fnews\u002fLists\u002fPhotos\u002fForms\u002fDispForm.aspx";
ctx.editFormUrl = "\u002fnews\u002fLists\u002fPhotos\u002fForms\u002fEditForm.aspx";
ctx.isWebEditorPreview = 0;
ctx.ctxId = 1;
g_ViewIdToViewCounterMap[ "{FE7A0018-7358-4B70-972D-5799B43F095C}" ]= 1;
ctx.CurrentUserId = -1;ví dụ site của tôi trong trường hợp trên. có lúc bạn sẽ cần chúng.
Ngòai ra trong source ta sẽ thấy đọan script sau:
Đọan script này dc lặp lại tương ứng với số lượng row trong list.
Để ý hàm InsertItem nó dc định nghĩa trong IMGLIB.JS:
function InsertItem(originalImageUrl, id, baseName, extension, imgWidthStr, imgHeightStr, titleStr, descriptionStr, objectType, iconUrl, fNewItem)
{
if (originalImageUrl=="")
return;
items[id]=new CItem(originalImageUrl, id, baseName, extension, imgWidthStr, imgHeightStr, titleStr, descriptionStr, objectType, iconUrl, fNewItem);
if (firstId==-1) firstId=id;
ids[ids.length]=id;
} Ở đây có hàm CItem sẽ add các thông số vào mảng items <- mọi thông tin của từng row trong list sẽ nằm trong mảng này --> ta đã có mọi thứ.Vấn đề giờ sao lấy dc id ?
Quay lại giao diện, ta để ý mỗi nút nhấn sổ xuống context menu đều có hàm ClickRow kèm với tham số ID tương ứng với dòng dc click, hàm này cũng ở trong IMGLIB.JS
function ClickRow(id)
{
if (!fImglibDefautlView) return;
if (tbPreview==null)
return;
if (id < 0 || items[id]==null)
return;
if (browseris.ie)
event.cancelBubble=true;
HiLiteRow(id);
ILShowMenu(id);
}Coi hàm ILShowMenu , trong hàm này có dòng itemTable=menuTR.parentNode.parentNode;trả về tòan bộ html tương ứng của cột có context menu của từng dòng dc click.
Trong đọan html này có thuộc tính id, ta chỉ cần get attribute về và cắt lấy chuỗi id vì nó dc ghép với "title"+id.
var txtID=itemTable.childNodes[0].childNodes[0].getAttribute("id");
var id=txtID.substr(5); Update 10/9/2010
Sau time tiếp tục nghiên cứu thấy: đọan script InsertItem chỉ có ở view có style là Picture Library Details , còn chỉnh sang
view có style khác như Basic Table thì sẽ ko lấy dc biến Items...-->đau đầu.
Khắc phục tạm thời: dùng js hoặc jquery để select trong source tìm giá trị phù hợp
0
comments
Labels:
Sharepoint
Subscribe to:
Posts (Atom)
