产品一张表luckysheet前端代码库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
3.3 KiB

5 years ago
# Table Data
5 years ago
5 years ago
## Get table data
5 years ago
5 years ago
- **Configuration**:
5 years ago
5 years ago
Configure the address of `updateUrl`, Luckysheet will request the table data through ajax. By default, all `data` in the sheet data with status 1 is loaded, and the rest of the sheet loads all fields except the `data` field.
5 years ago
5 years ago
- **Format**:
5 years ago
5 years ago
The luckysheetfile example is as follows:
5 years ago
```json
[
{
"name": "Sheet1",
"color": "",
"status": "1",
"order": "0",
"celldata": [],
"config": {},
"index": 0
},
{
"name": "Sheet2",
"color": "",
"status": "0",
"order": "1",
"data": [],
"config": {},
"index": 1
},
{
"name": "Sheet3",
"color": "",
"status": "0",
"order": "2",
"data": [],
"config": {},
"index": 2
}
]
```
5 years ago
## Get sheet data
5 years ago
5 years ago
- **Configuration**:
5 years ago
5 years ago
Configure the address of `loadSheetUrl`, the parameters are `gridKey` (table primary key) and `index` (sheet primary key collection, format is `[1,2,3]`), the returned data is the `data` field set of sheet
5 years ago
5 years ago
- **Format**:
5 years ago
```json
{
5 years ago
"1": [{r:0, c:1, v:"value 1"},{r:10, c:11, v:"value 2"}],
5 years ago
"2": [data],
"3": [data],
}
```
5 years ago
- **Explanation**:
5 years ago
5 years ago
`r` stands for row, `c` stands for column, and `v` stands for the value of the cell. The value can be a character, number, or json string.
The data will only be loaded once, generally speaking, there is only one primary key, but considering that some formulas, charts and pivot tables will refer to the data of other sheets, the front desk will add a judgment, if the current sheet refers to the data of other sheets, then complete the data of the referenced sheet together.
5 years ago
5 years ago
## Get range data
5 years ago
5 years ago
- **Configuration**:
5 years ago
5 years ago
Configure the address of `loadCellUrl`, the parameters are `gridKey` (table primary key), `index` (sheet primary key), start row, end row, start column, end column. The backend gets the specified celldata data according to the range and returns it.
5 years ago
5 years ago
## Update data
5 years ago
5 years ago
- **Configuration**:
5 years ago
5 years ago
Configure the address of `updateUrl`, and the parameter sent to the backend is a json string.
5 years ago
5 years ago
- **Format**:
5 years ago
```json
{
compress: false,
gridKey:10004,
5 years ago
data: [update data]
5 years ago
}
```
5 years ago
- **Explanation**:
5 years ago
5 years ago
| Parameter | Explanation | Example |
5 years ago
| ------------ | ------------ | ------------ |
5 years ago
| compress | Luckysheet uses client pako for zlib parameter compression, which is true if the browser supports compression, otherwise false. The backend can decide whether to decompress the data content based on this parameter | The process of obtaining parameters on the server side: 1. Serialize json string 2. Decode the data field if the compress field is TRUE 3. Decode the data string URLDecoder.decode(utf-8) |
| gridKey | Luckysheet file identifier | none |
| data | An array containing updated data. For the parameter format in the array, please see the introduction below. In the example: `t` indicates the update type, `i` is the index of the sheet, `c` is the row number, `r` is the column number, and `v` is the value | `data: [{ t : 'cell', i:0, c : 0, r : 0 , v: 2 }]` |