FineUI使用记录

@{
ViewBag.Title = "Grid/Grid";
var F = Html.F();
}

@section body {

@(F.Grid().IsFluid(true).CssClass("blockpanel").Title("表格").ShowHeader(true).ShowBorder(true).ID("Grid1").DataIDField("SaleAfterDTID").DataTextField("SaleAfterDTID")
.Columns(
F.RowNumberField(),
F.RenderField().HeaderText("处理类别").DataField("DealType").Width(120),

F.RenderField().HeaderText("原因分类").DataField("ReasonClass").Width(200),

F.RenderField().Width(80).EnableHeaderMenu(false).RendererFunction("renderActions")

)
.DataSource(ViewBag.DataSource)
)
<br>
<br>

@(F.Button().Text("选中了哪些行").ID("Button1").Listener("click", "notifySelectedRows('Grid1');"))


@(F.Button().Text("新增一行").ID("Button2").Listener("click", "addRow();"))

}

 

@section script {

<script src="~/res/js/grid.js"></script>
<script>
var jsonData;
jsonData=eval(@Html.Raw(ViewBag.jsonData));
function jiang() {
alert("jiangyunfeng");
}
function renderActions(value, params) {
var deleteImageUrl = '@Url.Content("~/res/icon/delete.png")';
return '<a class="action-btn delete" href="javascript:;"><img class="f-grid-cell-icon" src="' + deleteImageUrl + '"></a>';
}

function addRow() {
var grid1 = F.ui.Grid1;

// 新增一行(返回新增行的ID)
var addDa = {

'DealType': '前台添加的1',
'ReasonClass': '前台添加的2'
};
var addedRowId = grid1.addNewRecord(addDa, true);
addDa.rowIndex = addedRowId;
jsonData.push(addDa);
// alert(addedRowId);
}

F.ready(function () {
if (jsonData) {
var grid1 = F.ui.Grid1;
var gridData = grid1.getMergedData();
$.each(gridData, function (index, itme) {
jsonData[index].rowIndex = itme.id;
});
}

//alert(jsonData[1].ReasonClass);

//F.ui.btnSelectItem6.on('click', function () {
// alert('按钮的单击');
//});

//F.ui.DropDownList1.el.on('select', function () {
// alert('下拉的单击2');
//});

function getRowData(rowdata) {
alert(rowdata.id);
}

var grid1 = F.ui.Grid1;
grid1.el.on('click', 'a.action-btn.delete', function (event) {
var cnode = $(this);
var rowData = grid1.getRowData(cnode.closest('.f-grid-row'));

getRowData(rowData);
});
});

</script>
}

posted @ 2019-11-03 17:16  咖啡无眠  阅读(603)  评论(0编辑  收藏  举报