1) Get the cell Value by specifying the column name
2) Get the visible row Indexes
3) Select all the child rows
4) Fetch a Row given its index
5) Select a row given its index
regards,
Satish
11 Answers, 1 is accepted
Iam evaluating RadGridView to replace our existing Grid, hence looking for API details. Would appreciate much if anyone can pick this thread.
Thanks,
Satish J
Thank you for considering our product.
Here is how you can use RadGridView's API to achieve the desired results:
For versions prior Q2:
| private object GetCellValue(GridViewRow row, string columnName) |
| { |
| var column = this.RadGridView1.Columns[columnName]; |
| var columnIndex = this.RadGridView1.Columns.IndexOf(column); |
| return ((GridViewCell)row.Cells[columnIndex]).Value; |
| } |
| private GridViewRow FetchRow(int index) |
| { |
| var record = this.RadGridView1.Records[index]; |
| return (GridViewRow)this.RadGridView1.ItemsControl.ItemsGenerator.ContainerFromItem(record); |
| } |
| private void SelectRow(int index) |
| { |
| var record = this.RadGridView1.Records[index]; |
| this.RadGridView1.SelectedRecords.Add(record); |
| } |
| private int GetRowIndex(GridViewRow row) |
| { |
| return ((DataRecord)row.Record).DataSourceIndex; |
| } |
| private void SelectAllRows() |
| { |
| this.RadGridView1.SelectAll(); |
| } |
With Q2 we began go eliminate the usage of records which are now deprecated and will be removed in a future major relase. With Q2 2009 we began to promote the usage of data items instead of records.
For Q2 2009 SP1:
| private object GetCellValue(GridViewRow row, string columnName) |
| { |
| var column = this.RadGridView1.Columns[columnName]; |
| var columnIndex = this.RadGridView1.Columns.IndexOf(column); |
| return ((GridViewCell)row.Cells[columnIndex]).Value; |
| } |
| private GridViewRow FetchRow(int index) |
| { |
| var dataItem = this.RadGridView1.Items[index]; |
| return (GridViewRow)this.RadGridView1.ItemsControl.ItemsGenerator.ContainerFromItem(dataItem); |
| } |
| private void SelectRow(int index) |
| { |
| var dataItem = this.RadGridView1.Items[index]; |
| this.RadGridView1.SelectedItems.Add(dataItem); |
| } |
| private int GetRowIndex(GridViewRow row) |
| { |
| return this.RadGridView1.Items.IndexOf(row.DataItem); |
| } |
| private void SelectAllRows() |
| { |
| this.RadGridView1.SelectAll(); |
| } |
Could you clarify some of the points that you have mentioned? For question number 2 I am not sure if you would like to get the indices of all visible rows or an index of a specific row? And for question number 3 if child rows refers to the rows of a grid in flat scenario or to the rows of a grid in hierarchical scenario.
Once again thank for your interest in our product. Do not hesitate to write if you have further questions.
Sincerely yours,
Milan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Hi Milan,
Thanks for your reply, much appreciated. Here are my answers:
Question 2: Im looking to fetch the indices of all the visible rows as we may hide certain rows based on conditions
Question 3: Child row refers to rows in hierarchial scenario.
Would be great if you could confirm the availability of the following requirements in your API as we need to finalise soon.
1) ReadOnly grid
2) Sort the grid given its column index and sort order
3) Unselect all child rows
4) Select all child rows
5) Expands the rows specified in the Array
6) Set the filterby criteria given its filter text
7) Set a filter for a column
8) Set a Groupby criteria given its groupby text
9) Set a Row Focus given its row index
10) Select the rows specified in an Array
11) Set a value for a given its Row, Column and the text
12) UnSelect all the child rowsgiven its parent row index
Many Thanks
Satish J
Thanks,
Satish J
Regarding API avalability I have checked and here is the status:
1) ReadOnly grid - SUPPORTED
2) Sort the grid given its column index and sort order - SUPPORTED
3) Unselect all child rows - SUPPORTED
4) Select all child rows - SUPPORTED
5) Expands the rows specified in the Array - SUPPORTED ( depending on clients scenario)
6) Set the filterby criteria given its filter text - SUPPORTED
7) Set a filter for a column - SUPPORTED
8) Set a Groupby criteria given its groupby text - SUPPORTED
9) Set a Row Focus given its row index - SUPPORTED
10) Select the rows specified in an Array - SUPPORTED
11) Set a value for a given its Row, Column and the text - SUPPORTED ( depending on source collection)
12) UnSelect all the child rowsgiven its parent row index - SUPPORTED
Once you start implementing your project we will be glad to provide any help needed. Do not hesitate to open a support ticket if you find any troubles implementing the above functionality .
Regards,
Pavel Pavlov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Hi Pavel Pavlov,
Thanks for the prompt response. We are close to finalising the Grid. We also got the following additional requirements. Please let me know if these are achievable using your API.
1) Get only the visible row indexes
2) Set an Image for a column
3) ShowHeaderExpander
4) Hide a column
5) GetColumn count of only visible columns
6) Hierarchial grid column resize should be reflected on to child rows
Thanks,
Satish J
Hi Satish J,
Here is the updated list :
1) Get only the visible row indexes - Not Supported internally but ACHIEVABLE via few lines of codebehind.
2) Set an Image for a column - SUPPORTED
3) ShowHeaderExpander - please give more details on this so I can check ...
4) Hide a column - SUPPORTED
5) GetColumn count of only visible columns - SUPPORTED
6) Hierarchial grid column resize should be reflected on to child rows - depending on the scenario, possibly may be ACHIEVABLE via external code.
Again , thank you for evaluating our controls!
If you find any troubles implementing any of the features mentioned, do not hesitate to contact me . I will gladly provide you assistance by preparing an example or providing a piece of code ready to be pasted into your project.
Sincerely yours,
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thanks much appreciated. Can you also confirm these 2 requirements. It seems to have been missed out in the previous list:
1) Get the Child Column Index, given its Name and the row's level (like 2 for 2 levels nested in case of a hierarchial grid).
2) Get the child row count given a row index.
Thanks,
Satish J
1) Get the Child Column Index, given its Name and the row's level (like 2 for 2 levels nested in case of a hierarchial grid).- Supported with a few lines of external code *
2) Get the child row count given a row index.- Supported with a few lines of external code*
* Please have in mind that "row index " is kind of vague term.
Rows in RadGridView are dynamically created and virtualized. This means that only rows that are visible are currently created. The UI virtualization technique applied gives a lots of performance benefits and memory savings.
Greetings,
Pavel Pavlov
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Especaily with Hirerchical Grid API
Like Child Row count, Column Index, Row index which ever i select irrespective of Level (Hirerchical)
If possible i have attached image of my requirement... could u please visit .. and provide me the sample