BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
columns: [
{ field: "EmployeeID",isPrimaryKey:true, headerText: 'Employee ID', textAlign: ej.TextAlign.Right, width: 75 },
…… {
headerText: "Manage Records",
commands: [
{ type: ej.Grid.UnboundType.Delete, buttonOptions: { text: "Delete" } }
],
isUnbound: true, width: 130
}
], |
$("#Grid").ejGrid({
dataSource: data,
….
,
columns: [
{ field: "EmployeeID",isPrimaryKey:true, headerText: 'Employee ….
ej.TextAlign.Left, width: 100 },
{
headerText: "Employee Details",
commands: [
{
type: "details",
buttonOptions: {
text: "Details",
width: "100",
click: "onClick"
}
}
],
isUnbound: true,
textAlign: ej.TextAlign.Left,
width: 150
}
],
……..
});
});
function onClick(args) {
var grid = $("#Grid").ejGrid("instance");
var row = this.element.closest("tr");
var index = row.index();
var record = grid.getCurrentViewData()[index];
// do your operations here.
} |
Query |
Response | ||
Query1: As you can see have child grid, when I click on the Remove button on a row inside a child grid, I couldn't find a way to get the record and remove it from the child gird. (only from the table) |
Previously, we have mentioned that delete the childgrid row using type and buttonOptions properties of commands. Please refer to the below code example and sample.
In the Click event we are able to get the row details using getCurrentViewData method of grid. Refer to the following code example.
| ||
Query2: Also I would like to know how can I add new row to a specific child grid, but the parent Id (tradeId in the example above)
|
In child grid, row will be added based on parentId(EmployeeID).For example if parentid is 2 and adding new row for corresponding child grid then parent id (EmployeeID) for new row is automatically set as 2.Please refer to the below code example.
If we have misunderstood your requirement, share the following information to find the cause of the issue and provide a solution
1. You want to add new row based on parent id?
2. Added row data should reflect in your database?
|
App.component.html
<ej-grid #grid [allowpaging]="true" [allowsorting]="true" [datasource]="gridData" [childgrid]="childData" >
<e-columns>
<e-column field="EmployeeID" headertext="Employee ID" width="85" textalign="right"></e-column>
. . .
</e-columns>
App.component.ts
export class GridComponent {
public gridData: any;
public childData: any;
@ViewChild('grid') Grid: EJComponents<any, any>;
constructor() {
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true};
this.childData = {
dataSource: ej.DataManager({ url: " http://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders", crossDomain: true }),
queryString: "EmployeeID",
allowPaging: true,
{ field: "OrderID", headerText: 'Order ID', isPrimaryKey: true , textAlign: ej.TextAlign.Right, width: 75 },
{ headerText: "Employee Details",
columns: [
commands: [
{
type: "details",
buttonOptions: {
text: "Detail",
width: "100",
click: function(args) {
var id = $(".e-detailcell").children().attr("id")
var grid = $("#"+id).ejGrid("instance");
var index = this.element.closest("tr").index();
var record = grid.getCurrentViewData()[index];
console.log(record);
}
}
}
],
isUnbound: true,
textAlign: ej.TextAlign.Left,
width: 150
},
],
}
}
} |