0.1.3 • Published 1 year ago

@smallpot/demo01 v0.1.3

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Install

npm install table-layout

opts Attributes

参数说明类型是否必传默认值
xDrag是否开启横向拖拽Boolean可选true
yDrag是否开启纵向拖拽Boolean可选true
rowHeight默认行高Number可选32
columnWidth默认列宽Number可选100
tablePropstable标签配置项(props)Object可选{ className:[],style:{},attr:{} }
tbodyPropstbody标签配置项(props)Object可选{ className:[],style:{},attr:{} }
trPropstr标签配置项(props)Object可选{ className:[],style:{},attr:{} }
tdPropstd标签配置项(props)Object可选{ className:[],style:{},attr:{} }

标签配置项(props)

字段说明类型是否必传默认值
className标签类名,eg:"aClassName","bClassName"Array可选[]
style标签内联样式,eg:{ color:"red",backgroundColor:"green" }Object可选{}
attr标签自定义属性,eg:{ isOpen:true }Object可选{}

Events

方法名说明参数是否必传默认值
active对象初始化,启用事件监听---
mergeTdFn合并选中单元格---
disassemblyFn拆解选中单元格---
delEntireColumn删除选中单元格整列---
delEntireRow删除选中单元格整行---
insertColumnBefore选中单元格左侧插入列Number可选1
insertColumnAfter选中单元格右侧插入列Number可选1
insertRowAhead在选中单元格前方插入行Number可选1
insertRowBehind在选中单元格后方插入行Number可选1
cancelAllSelected取消选中单元格---
setOpts设置optsObject必填{}
setSelectAreaStyle设置选择区域样式Object可选{ width:"",height:"",boxSizing:"border-box",backgroundColor:"rgba(0, 0, 0, 0.1)",border:"2px solid rgb(31, 187, 125)",position: "absolute",left:"",top:"",pointerEvents:"none"}
getSelectArr获取选中单元格---

Example

<div class="menu">
     <button type="button" id="mergeTd" >合并</button>
     <button type="button" id="insertColumnAfter">右侧插入列</button>
</div>

<table id="tableBox">
  <tr>
    <td>单元格</td>
    <td>单元格</td>
    <td>单元格</td>
    <td>单元格</td>
  </tr>
  <tr>
    <td>单元格</td>
    <td>单元格</td>
    <td>单元格</td>
    <td>单元格</td>
  </tr>
</table>


<script type="module">
  import TableJar from "./TableJar.js"

  let obj=new TableJar(document.getElementById("tableBox"),{
    yDrag:false,//是否开启纵向拖拽
    tableProps:{
      className:[],
      style:{},
      attr:{}
    }
  });

   document.getElementById("mergeTd").addEventListener('click',e=>{
      obj.mergeTdFn();
   })
   document.getElementById("insertColumnAfter").addEventListener('click',e=>{
      obj.insertColumnAfter(1);
   })

</script>
0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago