Image Added
Lookup table maintenance in SynWeb is made up of two reusable controls that need to be included to work properly. The two controls are:
- The dropdown and menu (seen in the image above)
- The dynamically created popup with is populated with all the fields of the relevant lookup table.
These can be included by adding the following lines to the source code of your page
Code Block |
---|
|
<%@ Register Src="~/UserControl/UCtrlLookupTableMaintPopup.ascx" TagName="UCtrlLookupTableMaintPopup" TagPrefix="uc1" %>
<%@ Register Src="~/UserControl/UCtrlLookupTableMaint.ascx" TagName="UCtrlLookupTableMaint" TagPrefix="uc2" %> |
From there you can drop the "UCtrlLookupTableMaint" control where you want the drop down, you will also have to set a number of variables at this time:
Code Block |
---|
|
<uc2:UCtrlLookupTableMaint ID="LocationLookupTableMaint" runat="server" TableName="luLocation" MaintenanceScreen="ExcursionMaintenance" PanelName="Location" /> |
Variables are as follows:
- TableName → The name of the lookup table you wish to maintain. e.g. luLocation, luState etc.
- MaintenanceScreen → The name of the maintenance area you are in. e.g. ExcursionMaintenance, CommunityMaintenance etc.
- PanelName → The Panel the control is on e.g. Location, Details etc.
You will also need to reference the popup control like so:
Code Block |
---|
|
<uc1:UCtrlLookupTableMaintPopup ID="UCtrlPopupLookupTableMaint" runat="server" /> |
The above will add the component to the page. There are some code changes that need to be made in order to ensure everything works as expected. They are:
- Adding the table name to the methods that return the values for a particular lookup code, insert a new record, and update an existing record. This only needs to be done once per table for the following methods of CSharp\Synergetic\Synergetic.Database\DataAccessManager.cs
- GetLookupTableRow
- UpdateLookupTableRow
- InsertLookupTableRow
You will also need to add the onChange event to the control in the relevant javascript file
Code Block |
---|
|
//when creating the control, the id is in the following format "LookupMaintComboBox" + PanelName + TableName
//code added to the init to attach the handler
LookupMaintComboBoxLocationluLocation.valueOf().ValueChanged.AddHandler(function () {
publicMethods.LookupComboBoxChangeValue(LookupMaintComboBoxLocationluLocation.GetValue());
});
//new public function
LookupComboBoxChangeValue: function (selectedCode) {
try {
var ajaxModel =
{
action: 'GetLookupTableRow',
LookupTable: 'luLocation', //replaceTableName
Code: selectedCode,
getdataflag: _ajax.returnData.Yes
};
$.ajax({ type: 'POST', url: _locationAjaxURL, data: ajaxModel })
.done(function (dData) {
privateMethods.RefreshData(JSON.parse(dData.Data));
})
.fail(function (fData) {
_em.OnError(_controls.ErrorControl, new Error(fData.responseJSON.ServerMessage), '_Syn.{0}.Panels.{1}.{2}'.IFormat(_SynMaintPage, PanelName, 'Load'));
})
.always(function () {
_me.loadingPanel.Hide();
});
}
catch (e) {
_em.OnError(_controls.ErrorControl, e, '_Syn.{0}.Panels.{1}.{2}'.IFormat(_SynMaintPage, PanelName, 'Load'));
}
} |