|
|||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
Introduction
BackgroundFrankly speaking I’ve inspired to develop this control from the Class
Constructor
var Args = {
Base: _Base, //Base reference where ListBox to be displayed.
HeaderText: _ HeaderText, // Header Text.
Width: _Width, // Width of the Control.
ClickEventHandler: _ClickEventHandler // Reference of the click event handler.
};
Example: var Args = {
Base: document.getElementById('parent'),
HeaderText: 'Items',
Width: 200,
ClickEventListener: OnClick
};
In case you asign each
Methods
Note: The var PItem = {
IsSelected: _IsSelected, // true/false.
Text: _Text, // Item Text.
Value: _Value, // Item Value.
};
Property
Event
The local anonymous method that responds to the var EventHandler = function(Sender, EventArgs) {}
where var EventArgs = {
Text: _Text, // Item Text.
Value: _Value, // Item Value.
};
Using the ControlAdd the reference of the Panel.js file in your web pag:<script type="text/javascript" src="JS/Panel.js"></script>
Create an <div id="parent"></div>
Now Create a <script type="text/javascript">
var oPanel = null;
window.onload = function()
{
var Args = {
Base: document.getElementById('parent'),
HeaderText: 'Items',
Width: 200,
ClickEventListener: OnClick
};
oPanel = new Panel(Args);
oPanel.InsertItem('MSDN', 'Insert');
oPanel.InsertItem('HotMail', 'Delete');
oPanel.InsertItem('Yahoo', 'Update');
oPanel.InsertItem('Gmail', 'Cancel');
oPanel.InsertItem('Rediff', 'Truncate');
oPanel.InsertItem('AOL', 'Select');
oPanel.InsertItem('Hi5', 'Between');
}
</script>
In the above code, First an ClickEventListener: OnClick
Where OnClick is the reference of the click event handler that is created as a local anonymous method –
var OnClick = function(Sender, EventArgs)
{
//Code
}
Example: var OnClick = function(Sender, EventArgs)
{
var Message = new Array();
Message.push('Text: ' + EventArgs.Text);
Message.push('Value: ' + EventArgs.Value);
document.getElementById('DivMessage').innerHTML = Message.join('<br />');
}
The above method will gets called when ever you Invoke the window.onunload = function(){ oPanel.Dispose(); }
ConclusionSo this is the approach that I have adopted to develop Expandable / Collapsable Panel Control through Browser CompabilityI have tested this Panel Control on a number of web browsers.
| ||||||||||||||||||||||||||||||