Hi, We need some help on infragistics jquery controls for MVC 4.0. 1)How to get row from hierarchical grid without using any loops. is their any method like getRowByDataID or something else. 2)How we will change any row content of hierarchical grid and that should be commited to the attached datasource. eg. we have one column called isactive if I change this column to active its changing the grid row value but that value is not updated in datasource. so if I filter it by only active rows its not showing me that changed row. 3)Is there any property to assign color to the row in hierarchical grid. 4)normally without expanding the hierarchical grid we did not get its childern rows. is there any possibility to get all rows without expand. 5)We hide 2-3 columns for GridModel. but those columns are not able to get in javascript code. So is there any way to hide columns.
Hello gshontz ,
Thank you for posting in our forum. Please find the answers to your questions below:
---
Q1)How to get row from hierarchical grid without using any loops. is their any method like getRowByDataID or something else
If you’re aiming to get the Dom element associated with a specific data key of a row then you can use the “rowById” method:
http://help.infragistics.com/jQuery/2014.1/ui.iggrid_hg#methods:rowById
--
Q2)How we will change any row content of hierarchical grid and that should be commited to the attached datasource. eg. we have one column called isactive if I change this column to active its changing the grid row value but that value is not updated in datasource. so if I filter it by only active rows its not showing me that changed row.
You can use the “setCellValue” method of the igGridUpdating widget to update a specific cell value in the grid programmatically.
http://help.infragistics.com/jQuery/2014.1/ui.iggridupdating_hg#methods:setCellValue
If the autoCommit property of the grid is set to true (http://help.infragistics.com/jQuery/2014.1/ui.iggrid_hg#options:autoCommit ) then the changes will be reflected on the data source on the client side.
Otherwise you would need to explicitly call the “commit” method: http://help.infragistics.com/jQuery/2014.1/ui.iggrid_hg#methods:commit
After the changes are saved on the client side if you wish to commit them to the server side and invoke the action associated with the UpdateUrl that you have set for the grid, you would need to call the “saveChanges” method:
http://help.infragistics.com/jQuery/2014.1/ui.iggrid_hg#methods:saveChanges
Q3) Is there any property to assign color to the row in hierarchical grid.
There’s no specific property. If you need to set some style for a specific row you can get the Dom element associated with the row and using jQuery’s css() method apply the properties you want to it.
To get a specific row’s Dom element:
To apply css() to a Dom element:
http://api.jquery.com/css/
Q4)normally without expanding the hierarchical grid we did not get its children rows. is there any possibility to get all rows without expand
Before the row is expanded the child grid is not yet created on the page Dom. Only after expanding the parent row the child grid is created and instantiated on the page.
So before the row is expanded it is not possible to get the child grids or their rows as they don’t exist yet.
Q5)We hide 2-3 columns for GridModel. but those columns are not able to get in javascript code. So is there any way to hide columns.
In order to hide/show columns on the client side the Column Hiding features needs to be defined for the grid.
http://www.igniteui.com/grid/column-hiding
Then via the features API you can hide/show columns using the related methods (hideColumn and showColumn):
http://help.infragistics.com/jQuery/2014.1/ui.iggridhiding_hg#methods:hideColumn
http://help.infragistics.com/jQuery/2014.1/ui.iggridhiding_hg#methods:showColumn
Let me know if you have any additional questions or concerns.
Best Regards,
Maya Kirova
Developer Support Engineer II
Infragistics, Inc.
http://ko.infragistics.com/support
Hi,
Thanks for your reply.
I checked your suggested links. It solved some of the problems.
But still we are not able to get rows by its ID. Actually we are using hierarchical grid. and in this grid we have used grid model.
now we have attached one primary key column to dataid of grids.
But using rowbyID we are not getting the proper row. I need a row by using those dataID.
Also I want to expand all childrens without adding any loops for code. Is it any way for this.
1.By design when some action is triggered programmatically then the related client event will not be raised.
So if you programmatically expand a row the related expanding and expanded events will not be raised.
If you need an event that is associated with the creating of the child grid you can use the childGridCreated event:
http://help.infragistics.com/jQuery/2014.1/ui.ighierarchicalgrid#events:childGridCreated
2.If you’d like to set a specific filter for the whole child layout (all child grid) you could do so in the child grid layout’s declaration in the filtering feature.
You can set a default filter by setting the filtering feature for the child layout in the columnSettings for a specific column the defaultExpressions option. For example:
{
name: "Filtering",
type: "local",
columnSettings : [
columnKey: "FirstName",
defaultExpressions: [
{ expr: "N", cond: "startsWith" }
]
}
In the above example the column with key “FirstName” will be filtered so that only values starting with “N” will be displayed.
If you’d like to set a filter when on a specific child grid based on some condition I would suggest using the childGridCreated client event:
http://help.infragistics.com/jQuery/2014.1/ui.ighierarchicalgrid#events
The event will fire after the child grid is created. You can get it’s related Dom element from ui.element and apply the additional filtering expression using the filter() method:
http://help.infragistics.com/jQuery/2014.1/ui.iggridfiltering_hg#methods:filter
Let me know if you have any questions or concern regarding this.
Thanks for your valuable help. The given example solved our many problems.
But still have 2 problems.
1) I did the code to expand the parent row by using its Ids. The grid is expanding but its not executing the Expanded Event.
But if I click on expand button on grid to expand the row. then expanding event is working properly.
For expand the row we have used this code sample.
var
parentGrid = $(
"#idGrid"
).igHierarchicalGrid(
"rootWidget"
),
rowDomElement = parentGrid.allRows()[0];
$(
".selector"
"expand"
, rowDomElement);
//Bind after initialization
).live(
"ighierarchicalgridrowexpanded"
,
function
(evt, ui) {
//return the triggered event
evt;
//pointer to the object that triggers the event, which in our case is igHierarchicalGrid
evt.target;
//pointer to the object that listins for the event, which in our case is igHierarchicalGrid
evt.currentTarget;
//the type of the event, which following the jquery UI convention is 'ighierarchicalgridrowexpanded'
evt.type;
//reference to the Hierarchical grid widget
ui.owner;
//gets all igHierarchical Grid widgets
ui.owner.allChildrenWidgets;
//jQuery wrapper of the parent row object
ui.parentrow;
//get the HTML DOM row object
ui.parentrow[0];
});
//Initialize
).igHierarchicalGrid({
rowExpanded :
(e, args) {...}
But when I expand the parent row its shows me expanded. But not executing the expanded event.
2)As per the understandings the child grid is created when we expand any row. But consider we did not expanded any row. and we want to apply filter then How it will work.
Hope for your reply.
Thanks,
gshontz
Note that if you’re aiming to get a row that belongs to a specific child grid, the target for the method will need to be the child grid, not the main grid.
For example:
var child=$("#hierarchicalGrid").igHierarchicalGrid("allChildren")[0];
var row=$(child).igGrid( "rowById", 'Bread');
I’ve attached a sample with an igHierarchicalGrid that has two levels.
In order to get a row by the primaryKey corresponding to the row the code would be:
var row=$("#hierarchicalGrid").igGrid( "rowById", 'Food');
Where “hierarchicalGrid” is the id of the main grid.
And to get a row from a child the method needs to be called on the related child grid.
Please refer to the attached sample and let me know if you have any questions.