📄 listsheet.htc
字号:
end if
' create container DIVs
set elContainer = element.appendChild(element.document.createElement("DIV"))
elContainer.className = "lsListArea"
elContainer.style.width = "100%"
if bScroll then
elContainer.style.height = element.currentStyle.height
else
elContainer.style.OverflowY = "visible"
elContainer.style.MarginRight = "15px"
end if
' create empty and master table
set m_elEmptyTable = elTableTemp.cloneNode(true)
' emptyprompt and empty recordset
set elRow = m_elEmptyTable.insertRow()
set elCell = elRow.insertCell()
with elCell
if nCols > 1 then .colspan = nCols
.align = "center"
.nowrap = true
.style.cursor = "default"
if m_bDataFound then
.innerText = L_NoItemsMatch_Message
else
.innerText = L_SpecifyFind_Message
end if
end with
AddClass elRow, "lsRowSelected"
set m_elEmptyTable = elContainer.appendChild(m_elEmptyTable)
set m_elMasterTable = elTableTemp.cloneNode(true)
if m_bSelectAll then AddClass m_elMasterTable, "selected"
with m_elMasterTable
.tabIndex = "0"
.width = "100%"
.attachEvent "onmouseover", GetRef("HiliteRowEx")
.attachEvent "onmouseout", GetRef("RestoreRowEx")
.attachEvent "onclick", GetRef("onClickRow")
.attachEvent "ondblclick", GetRef("onDblClickRow")
.attachEvent "onkeydown", GetRef("onKeyDown")
.attachEvent "onfocus", GetRef("onTableFocus")
.attachEvent "onblur", GetRef("onTableBlur")
end with
set elMasterDataRow = m_elMasterTable.insertRow()
elMasterDataRow.setAttribute "name", "master"
if m_bGrouped then
elMasterDataRow.className = "lsRowClosed"
set elSubMasterRow = m_elMasterTable.insertRow()
elSubMasterRow.setAttribute "name", "subtable"
elSubMasterRow.style.display = "none"
set elCell = elSubMasterRow.insertCell()
with elCell
elCell.id = "lsgroupcell"
if nCols > 1 then .colspan = nCols
.style.padding = "0"
end with
end if
set m_elMasterTable = elContainer.appendChild(m_elMasterTable)
if m_bGrouped then
' create detail table
if m_bSubObject then
set m_elDetailTable = elGetSubObject()
m_elDetailTable.style.marginTop = "3px"
m_elDetailTable.style.marginBottom = "3px"
elSubMasterRow.style.background = "white"
else
set m_elDetailTable = elTableTemp.cloneNode(true)
m_elDetailTable.datafld = "record"
set elDetailDataRow = m_elDetailTable.insertRow()
elDetailDataRow.style.margin = "0"
elDetailDataRow.setAttribute "name", "detail"
end if
if m_bSubGrouped then
' create group table
set m_elGroupTable = elTableTemp.cloneNode(true)
m_elGroupTable.datafld = "record"
set elGroupDataRow = m_elGroupTable.insertRow()
elGroupDataRow.setAttribute "name", "group"
elGroupDataRow.className = "lsRowClosed"
set elSubGroupRow = m_elGroupTable.insertRow()
elSubGroupRow.setAttribute "name", "subtable"
elSubGroupRow.style.display = "none"
set elCell = elSubGroupRow.insertCell()
with elCell
if nCols > 1 then .colspan = nCols
.style.padding = "0"
end with
set m_elGroupTable = elSubMasterRow.firstChild.appendChild(m_elGroupTable)
set m_elDetailTable = elSubGroupRow.firstChild.appendChild(m_elDetailTable)
elseif m_bGrouped then
set m_elDetailTable = elSubMasterRow.firstChild.appendChild(m_elDetailTable)
end if
end if
' add page display
AddPageControls()
'get page size, recodcount and current page and set page controls
m_nPageSize = m_xmlMetaGlobal.getAttribute("pagesize")
if isEmpty(m_nRecordcount) then m_nRecordcount = m_xmlMetaGlobal.getAttribute("recordcount")
m_nCurPage = m_xmlMetaGlobal.getAttribute("curpage")
SetPageControls()
if nCols > 0 then
nDefaultWidth = CInt(100/nCols)
else
nDefaultWidth = 100
end if
' add columns to all tables for each meta column
for each xmlMetaCol in xmlColumns
'get id(s)
sMasterID = xmlMetaCol.getAttribute("id")
if m_bSubGrouped then
sGroupID = xmlMetaCol.getAttribute("id2")
sDetailID = xmlMetaCol.getAttribute("id3")
else
sGroupID = ""
sDetailID = xmlMetaCol.getAttribute("id2")
end if
'get column defaults
sFormat = xmlMetaCol.getAttribute("format")
sWidth = xmlMetaCol.getAttribute("width")
if isNull(sWidth) or not isNumeric(sWidth) or sWidth = "" then sWidth = nDefaultWidth
if CInt(sWidth) <= 0 then sWidth = nDefaultWidth
xmlMetaCol.setAttribute "width", sWidth
m_nTableWidth = m_nTableWidth + CInt(sWidth)
if bSort and not isNull(xmlMetaCol.getAttribute("sortdir")) then
m_sSortDir = xmlMetaCol.getAttribute("sortdir")
m_sSortCol = sMasterID
end if
if bHeaders then
' create header cell
AddHeaderCell sMasterID, xmlMetaCol.text, bSort, sWidth, nCols
end if
' create master data cell
set elCell = elGetCell(elMasterDataRow, sWidth)
if m_bGrouped then elCell.style.fontWeight = "bold"
if elMasterDataRow.cells.length = 1 then
' add key span used to identify the row
AddQueryID(elCell)
if m_bGrouped then
' add expand/collapse icon
AddExpandIcon(elCell)
end if
end if
AddBindSpan elCell, sMasterID, sFormat
if m_bGrouped and not m_bSubObject and _
m_xmlDataDoc.selectNodes("record/record").length > 0 then
' create detail data cell
set elCell = elGetCell(elDetailDataRow, sWidth)
if elDetailDataRow.cells.length = 1 then
elCell.style.paddingLeft = "2em"
' add key span used to identify the row
AddQueryID(elCell)
end if
AddBindSpan elCell, sDetailID, sFormat
if m_bSubGrouped then
elDetailDataRow.firstChild.style.paddingLeft = "3em"
' create group data cell
set elCell = elGetCell(elGroupDataRow, sWidth)
elCell.style.fontWeight = "bold"
if elGroupDataRow.cells.length = 1 then
elCell.style.paddingLeft = "1.5em"
' add key span used to identify the row
AddQueryID(elCell)
' add expand/collapse icon
AddExpandIcon(elCell)
end if
AddBindSpan elCell, sGroupID, sFormat
end if
end if
next
'create wait display
set m_elWaitDisplay = element.insertAdjacentElement("beforeEnd", element.document.createElement("DIV"))
with m_elWaitDisplay
.id = .uniqueID
.className = "waitDisplay"
.style.display = "none"
.noWrap = true
.style.setExpression "top", "(document.body.clientHeight/2) - 50 - (" & .id & ".offsetHeight/2)"
.style.setExpression "left", "(document.body.clientWidth/2) - (" & .id & ".offsetWidth/2)"
.innerHTML = "<img SRC='/widgets/images/statusanimation.gif' ALIGN='absmiddle' HEIGHT='36' WIDTH='36' STYLE='FILTER: invert'> " & L_Loading_Text
end with
'if totalwidth <> 100% then calculate percentage of totalwidth
if m_nTableWidth <> 100 then
'get pointers to all table cells
set elCells = m_elMasterTable.rows(0).cells
if m_bGrouped and not m_bSubObject then
if m_bSubGrouped then
set elSubGroupCells = m_elGroupTable.rows(0).cells
end if
set elDetailCells = m_elDetailTable.rows(0).cells
end if
for nCell = 0 to elCells.length - 1
nHeadCellWidth = xmlColumns(nCell).getAttribute("width")
if not isNull(nHeadCellWidth) then
'set to percentage of total
nHeadCellWidth = CLng(nHeadCellWidth/m_nTableWidth * 100) & "%"
m_elHeadTable.rows(0).cells(nCell + nCell).width = nHeadCellWidth
elCells(nCell).width = nHeadCellWidth
if m_bGrouped and not m_bSubObject then
if m_bSubGrouped and not elSubGroupCells(nCell) is nothing then
elSubGroupCells(nCell).width = nHeadCellWidth
end if
if not elDetailCells(nCell) is nothing then elDetailCells(nCell).width = nHeadCellWidth
end if
end if
next
end if
if bEmptyRecordset then
ShowEmptyPrompt()
else
ShowMasterTable()
end if
end sub
sub showContextMenuEx()
dim elKey, elSourceRow, sQueryID, sRow
set elSourceRow = elGetContainer(window.event.srcElement, "tagName", "TR")
set elKey = elSourceRow.firstChild.all("key")
window.event.returnValue = false
if elKey is nothing then exit sub
'cancel bubble since showing custom context menu
window.event.cancelBubble = true
'if multiselect mode and all selected then unselectall
if not (m_bMultiSelect and m_bSelectAll) and not bHasClass(elSourceRow, "lsRowSelected") then
'if not multiselect mode and something is already selected
' then unselect that row (loop will execute once)
if not m_bMultiSelect and m_dSelectedRows.count >= 1 then
for each sRow in m_dSelectedRows
SetSelected m_dSelectedRows(sRow), false
next
end if
'select the row
SetSelected elSourceRow, true
end if
sQueryID = elKey.innerText
set m_xmlContextRecord = m_xmlDataDoc.selectSingleNode("//record[bd_queryid $ieq$ '" & sQueryID & "']")
call showContextMenu(window.event.clientX, window.event.clientY)
end sub
sub showContextMenu(sX, sY)
dim sMenuWidth
if m_elBDContextMenu is nothing then exit sub
if m_elBDContextMenu.children.length = 0 then exit sub
sMenuWidth = replace(m_sContextMenuWidth, "px", "")
on error resume next
if sX + sMenuWidth > element.document.body.clientWidth then sX = sX - sMenuWidth
with m_elBDContextMenu.style
.posLeft = sX
.posTop = sY
.width = sMenuWidth
.display = ""
end with
m_elBDContextMenu.setCapture()
m_elBDContextMenu.focus()
end sub
sub closeContextMenu()
if m_elBDContextMenu is nothing then exit sub
m_elBDContextMenu.releaseCapture()
m_elBDContextMenu.style.display = "none"
end sub
sub toggleContextMenuHighlight()
dim elBDContextItem
set elBDContextItem = window.event.contextitem
if elBDContextItem.tagName = "U" then set elBDContextItem = elBDContextItem.parentElement
with elBDContextItem
if .disabled then exit sub
if .className = "bdcontextmenuitem" then
.className = "bdcontextmenuitemhighlight"
elseif .className = "bdcontextmenuitemhighlight" then
.className = "bdcontextmenuitem"
end if
end with
end sub
sub onContextMenuKeyDown()
dim evt, elSourceRow, elKey, sQueryID, sRow, sX, sY
set evt = window.event
if evt.keyCode = KEYCODE_F10 and evt.shiftKey then
'if multiselect mode and all selected then unselectall
set elSourceRow = m_elHighlighted
set elKey = elSourceRow.firstChild.all("key")
if elKey is nothing then exit sub
'cancel bubble since showing custom context menu
window.event.cancelBubble = true
if not (m_bMultiSelect and m_bSelectAll) and not bHasClass(elSourceRow, "lsRowSelected") then
'if not multiselect mode and something is already selected
' then unselect that row (loop will execute once)
if not m_bMultiSelect and m_dSelectedRows.count >= 1 then
for each sRow in m_dSelectedRows
SetSelected m_dSelectedRows(sRow), false
next
end if
'select the row
SetSelected elSourceRow, true
end if
sQueryID = elKey.innerText
set m_xmlContextRecord = m_xmlDataDoc.selectSingleNode("//record[bd_queryid $ieq$ '" & sQueryID & "']")
sY = element.offsetHeight/2
sX = element.document.body.clientWidth - element.offsetWidth
call showContextMenu(sX, sY)
evt.returnValue = false
evt.cancelBubble = true
end if
end sub
sub clickContextMenuItem()
dim evt, elBDContextItem
set elBDContextItem = window.event.contextitem
if elBDContextItem.tagName = "U" then set elBDContextItem = elBDContextItem.parentElement
if m_elBDContextMenu is nothing or elBDContextItem.disabled then exit sub
m_elBDContextMenu.releaseCapture()
m_elBDContextMenu.style.display = "none"
with elBDContextItem
if (.className = "bdcontextmenuitem" or _
.className = "bdcontextmenuitemhighlight") and _
not .disabled then
.className = "bdcontextmenuitem"
set evt = createEventObject()
evt.setAttribute "XMLrecord", m_xmlContextRecord
evt.type = "contextclick"
evt.setAttribute "srcContextItem", elBDContextItem
evtContextClick.fire(evt)
end if
end with
end sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -