如何使用另一个网格选定项更新网格 [英] how to update grid with another grid selected item
本文介绍了如何使用另一个网格选定项更新网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的主网格,我尝试在选择弹出网格时更新此网格,请帮助我
this is my main grid, i am try to update this grid on selection of popup grid, please help me
<a id="window"></a>
@(Html.Kendo().Grid<Models.AssetLocationViewModel>()
.Name("GridLocation")
.Columns(columns =>
{
//columns.Bound(p => p.UserId).Width(125);
columns.Bound(p => p.CampanyCode).Width(125);
columns.Bound(p => p.location1code).Width(165).Filterable(false);
columns.Bound(p => p.location2code).Width(150).Filterable(false);
columns.Bound(p => p.locationCode).Width(125);
columns.Bound(p => p.Name).Width(150);
columns.Bound(p => p.ShortName).Width(150);
columns.Bound(p => p.CreatedBy).Width(150);
columns.Bound(p => p.ModifyBy).Width(150);
//columns.Bound(p => p.Designation).Width(150);
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Sortable()
.Scrollable()
.Selectable()
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith("Starts with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
)))
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
//.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.locationCode))
.Create(update => update.Action("AssetLocEditingPopup_Create", "Location"))
.Read(read => read.Action("AssetLocationEditingPopup_Read", "Location"))
.Update(update => update.Action("AssetLocEditingPopup_Update", "Location"))
.Destroy(update => update.Action("AssetLocEditingPopup_Destroy", "Location"))
)
)
<script type="text/javascript">
$(document).ready(function () {
$("#GridLocation").on("dblclick", " tbody > tr > td", function () {
//model.location2code = 100;
//var grid = $("#GridLocation").data("kendoGrid");
//var data = grid.datasource.at(0);
////data.set("location1code", l1locode);
//alert(data.location1code);
//var gridDataArray = $('#GridLocation').data('kendoGrid')._data;
//var columnDataVector = [];
//var columnName = 'location1code';
////for (var index = 0; index < gridDataArray.length; index++) {
//// columnDataVector[index] = gridDataArray[index][columnName];
////};
////alert(columnDataVector[0]);
//gridDataArray[0].text("location1code", "frfrf");
//$("#locapopupWindow").data('kendoWindow').open();
$("#window").load("@Url.Action("PopupWindow", "Location")");
//$(this).load("/Shared/_assetLocationPopup");
$('#GridLocation').data('kendoGrid').refresh()
//firstItem.dirty = true; // set it as dirty
//$('#GridLocation').data().kendoGrid.dataSource.sync();
});
});
</script>
@{Html.Kendo().Window()
.Name("locapopupWindow")
.Title("Select Location")
.Draggable()
.Width(500)
.Height(300)
.Actions(actions => actions
.Custom("custom")
.Minimize()
.Maximize()
.Close()
)
.Content(@<text>
@{Html.Kendo().Grid<IBATechnologies.IBA.Web.Models.AssetLocationViewModel>()
.Name("locationpopupGrid")
.Columns(columns =>
{
columns.Bound(p => p.CampanyCode).Width(125).Visible(false);
columns.Bound(p => p.location1code).Width(165).Visible(false);
columns.Bound(p => p.location2code).Width(150).Visible(false);
columns.Bound(p => p.Name).Width(150);
columns.Bound(p => p.ShortName).Width(150);
columns.Bound(p => p.CreatedBy).Width(150).Visible(false);
columns.Bound(p => p.ModifyBy).Width(150).Visible(false);
})
.Pageable()
.Sortable()
.Scrollable()
.Selectable()
.Filterable(filterable => filterable
.Extra(false)
.Operators(operators => operators
.ForString(str => str.Clear()
.StartsWith("Starts with")
.IsEqualTo("Is equal to")
.IsNotEqualTo("Is not equal to")
)))
.HtmlAttributes(new { style = "height:250px;" })
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(10)
//.Events(events => events.Error("error_handler"))
.Model(model => model.Id(p => p.location1code))
.Create(update => update.Action("Level2LocEditingPopup_Create", "Asset"))
.Read(read => read.Action("Level2LocationEditingPopup_Read", "Location"))
)
.Render();
}
</text>
)
.Render();
}
<script>
$(document).ready(function () {
$("#locationpopupGrid").data("kendoGrid").bind("change", onLocationRowSelected);
$("#locapopupWindow").data("kendoWindow").bind("close", onWindowClose);
function onLocationRowSelected() {
var grid = $("#locationpopupGrid").data("kendoGrid");
var selectedItem = grid.dataItem(grid.select());
orisfunction(selectedItem.location1code, selectedItem.location2code);
$("#locapopupWindow").data("kendoWindow").close();
$("#locapopupWindow").data("kendoWindow").destroy();
}
function orisfunction(l1locode, l2locode) {
var grid = $("#GridLocation").data("kendoGrid");
var data = grid.dataSource.data()[0];
data.set("location1code", l1locode);
data.set("location2code", l2locode);
}
function onWindowClose() {
$("#locapopupWindow").data("kendoWindow").destroy();
}
});
</script><<code></code>
推荐答案
( document ).ready( function (){
(document).ready(function () {
( #GridLocation)。on( dblclick , tbody> tr> td,功能(){
// m odel.location2code = 100;
// var grid =
("#GridLocation").on("dblclick", " tbody > tr > td", function () { //model.location2code = 100; //var grid =
(#GridLocation)。data(kendoGrid);
// var data = grid.datasource.at(0);
// // data.set(location1code,l1locode);
// alert(data.location1code );
// var gridDataArray =
("#GridLocation").data("kendoGrid"); //var data = grid.datasource.at(0); ////data.set("location1code", l1locode); //alert(data.location1code); //var gridDataArray =
这篇关于如何使用另一个网格选定项更新网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文