国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) BootStrap editable table

BootStrap editable table

Dec 05, 2016 pm 02:15 PM
bootstrap

1. Display data (basic function)

Define the table and column names of the table in the html page, and finally display the data queried from the database to the page in a loop. This system uses PHP language, which uses the syntax in PHP. If it is Java language, just replace php with the corresponding syntax in jsp. In the page, first define a table and then initialize it in js. This function refers to a third-party plug-in, which can be downloaded here http://bootstrap-table.wenzhixin.net.cn/zh-cn/. This plug-in has modified http://bootstrap-table.wenzhixin.net.cn /zh-cn/ It is formed after some functions in it. During the use, I made some small changes. You can use them according to the situation

1. Effect display

After the table is initialized

Add new rows

2. When using , first you need to introduce its js, I quoted it uniformly into the entry file BootStrap editable table

<div class="containe">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr class="success">
<th>序號</th>
<th style="display: none">ActionID</th>
<th>Category</th>
<th>SubProcess Name</th>
<th>Description</th>
<th>Do Action</th>
</tr>
</thead>
<tbody>
<?php
//遍歷傳遞過來的變量$subprocess_info
$i=1;
foreach($subprocess_info as $_v){
?>
<tr id="">
<td><?php echo $i; ?></td>
<td style="display: none"><?php echo $_v->ActionID; ?></td>
<td><?php echo $_v->Category; ?></td>
<td><a href="#"><?php echo $_v->ActionName; ?></a></td>
<td><?php echo $_v -> Description; ?></td>
<td>
<a href="./index.php?r=subprocess/update&id=<?php echo $_v->ActionID; ?>">修改</a>
<a href="./index.php?r=subprocess/del&id=<?php echo $_v->ActionID; ?>">刪除</a>
</td>
</tr>
<?php $i++; }?>
</tbody>
</table>
</div>

BootStrap editable table Define the table on the page, you can add custom buttons

<!--表格編輯-->
<link href="./assets/tableEdit/css/bootstrap-table.min.css" rel="stylesheet" />
<script src="./assets/tableEdit/js/bootstrap-table.js"></script>
<script src="./assets/tableEdit/js/bootstrap-table-edit.js"></script>
<script src="./assets/tableEdit/js/bootstrap-select.js"></script>
<script src="./assets/tableEdit/js/bootstrap-datetimepicker.min.js"></script>
<link href="./assets/tableEdit/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />

3. js initialization form

<script src="./js/subprocess/subprocess.js"></script>
<div class="col-md-12">
<div style="float:right;margin:10px 0px 10px 5px">
<a title="Add" href="./index.php?r=subprocess/add">
<button type="button" class="btn btn-default" id="addData"<span style="color:#008000;background-color:#efefef;font-weight:bold;"></span>>
<span class="glyphicon glyphicon-plus"></span>
</button>
</a>
</div>
<table class="table table-striped table-bordered table-hover" id="subprocessTable"></table>
</div>

If you need to use a drop-down list, define it like this when defining the column

$(function(){
//初始化表格
$(&#39;#subprocessTable&#39;).bootstrapTable({
method: &#39;get&#39;,
url:"./index.php?r=subprocess/subprocessInfo",
editable:true,//開啟編輯模式
clickToSelect: true,
cache: false,
showToggle:true, //顯示切換按鈕來切換表/卡片視圖。
showPaginationSwitch:true, //顯示分頁切換按鈕
pagination: true,
pageList: [10,25,50,100],
pageSize:10,
pageNumber:1,
uniqueId: &#39;index&#39;, //將index列設(shè)為唯一索引
striped: true,
search: true,
showRefresh: true,
minimumCountColumns: 2,
smartDisplay:true,
columns: [
[
{field:"index",title:"ID",align:"center",edit:false,formatter:function(value, row, index){
return row.index=index ; //返回行號
}},
{field:"actionName",title:"ActionName",align:"center",order:"asc",sortable:"true",formatter:function(value,row,index){
var strHtml =&#39;<a href="./index.php?r=subprocess/modify&id=&#39;+ row.actionId +&#39;">&#39;+ row.actionName +&#39;</a>&#39;;
return strHtml;
}},
{field:"category",title:"Category",align:"center",sortable:"true"},
{field:"description",title:"Description",align:"center"},
{field:"action",title:"Action",align:"center",formatter:function(value,row,index){
var strHtml =&#39;<a href="./index.php?r=subprocess/modify&id=&#39;+ row.actionId +&#39;"><li class="glyphicon glyphicon-pencil"></li></a>&#39;+
&#39;<a href="javascript:void(0);" onclick="removeData(&#39;+ index +&#39;)" style="margin-left:5px;"><li class="glyphicon glyphicon-remove"></li></a>&#39;;
return strHtml;
},edit:false},
{field:"actionId",title:"ActionID",align:"center",edit:false,visible:false,searchable:false}
]
]
});
 
/**
* add a new row
*/
$(&#39;#addData&#39;).click(function(){
$(&#39;#subprocessTable&#39;).bootstrapTable(&#39;selectPage&#39;, 1); //Jump to the first page
var data = {actionId: &#39;&#39;, actionName: &#39;&#39;,category:&#39;&#39;, description: &#39;&#39;}; //define a new row data,certainly it&#39;s empty
 
$(&#39;#subprocessTable&#39;).bootstrapTable(&#39;prepend&#39;, data); //the method of prepend must defined all fields,but append needn&#39;t
//$(&#39;#dataTable&#39;).bootstrapTable(&#39;append&#39;,data);
 
$("#dataTable tr:eq(1) td:eq(0)").trigger("dblclick");
$("#dataTable input")[0].focus();
});
});

The effect is as follows

For other operations, you can check the documentation on the website of this plug-in, or look at the js source code

3. Dynamic header

Dynamic header, in the final analysis, the column data is not fixed each time. The database is queried according to the prerequisites, and the header is loaded according to the query results. With the above modifications, it is no longer a problem to implement this function. Just replace the columns of the initialization table with our custom data. I made a simple small demo. For details, you can see [EasyUi DataGrid] dynamically loading columns. The effect of this article BootStrap editable table

{field:"toRun",title:"Run Flag",align:"center",edit:{
type:&#39;select&#39;,//下拉框
url:&#39;./index.php?r=dictionary/dictionaryInfo&type=&#39;+"run",
//data:[{id:1,text:&#39;hello&#39;},{id:2,text:&#39;hi&#39;}],
valueField:&#39;id&#39;,
textField:&#39;text&#39;,
editable : false,
onSelect:function(val,rec){
//console.log(val,rec);
}
},sortable:true}


is as follows:

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

How to view the date of bootstrap How to view the date of bootstrap Apr 07, 2025 pm 03:03 PM

Answer: You can use the date picker component of Bootstrap to view dates in the page. Steps: Introduce the Bootstrap framework. Create a date selector input box in HTML. Bootstrap will automatically add styles to the selector. Use JavaScript to get the selected date.

How to get the bootstrap search bar How to get the bootstrap search bar Apr 07, 2025 pm 03:33 PM

How to use Bootstrap to get the value of the search bar: Determines the ID or name of the search bar. Use JavaScript to get DOM elements. Gets the value of the element. Perform the required actions.

How to verify bootstrap date How to verify bootstrap date Apr 07, 2025 pm 03:06 PM

To verify dates in Bootstrap, follow these steps: Introduce the required scripts and styles; initialize the date selector component; set the data-bv-date attribute to enable verification; configure verification rules (such as date formats, error messages, etc.); integrate the Bootstrap verification framework and automatically verify date input when form is submitted.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

10 latest tools for web developers 10 latest tools for web developers May 07, 2025 pm 04:48 PM

Web development design is a promising career field. However, this industry also faces many challenges. As more businesses and brands turn to the online marketplace, web developers have the opportunity to demonstrate their skills and succeed in their careers. However, as demand for web development continues to grow, the number of developers is also increasing, resulting in increasingly fierce competition. But it’s exciting that if you have the talent and will, you can always find new ways to create unique designs and ideas. As a web developer, you may need to keep looking for new tools and resources. These new tools and resources not only make your job more convenient, but also improve the quality of your work, thus helping you win more business and customers. The trends of web development are constantly changing.

See all articles