Hi,
I have found this thread: http://ko.infragistics.com/community/forums/t/71593.aspx
and had some success in adapting the answer to my needs.
What I'm still missing is a replace function and to highlight only the cells with the hits, not the whole rows.
How can I achieve that?
Best
Oliver
Hello Oliver,
Thank you for your post.
After working on the functionality that you are trying to achieve and doing some research , it has been determined to be a new product idea. You can suggest new Product Ideas for future versions (or vote for existing ones) at http://ideas.infragistics.com.
Steps to create your idea:
Log into the Infragistics Product Ideas site at http://ideas.infragistics.com (creating a new login if needed).
Navigate to the product / platform channel of your choice (e.g. WPF, Windows Forms, ASP.NET, HTML5 / Ignite UI, iOS / NucliOS, etc.)
Add your product idea and be sure to be specific and provide as much detail as possible.
Explain the context in which a feature would be used, why it is needed, why it can’t be accomplished today, and who would benefit from it. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. Be convincing!
Include a link to this thread in your idea so product management will be able to look back at this case.
The benefits of submitting the product idea yourself include:
Direct communication with our product management team regarding your product idea.
Notifications whenever new information regarding your idea becomes available.
Additional benefits of the Product Idea system include:
Ability to vote on your favorite product ideas to let us know which ones are the most important to you. You will have ten votes for this and can change which ideas you are voting for at any time.
Allow you to shape the future of our products by requesting new controls and products altogether.
You and other developers can discuss existing product ideas with members of our Product Management team.
The product ideas site allows you to track the progress of your ideas at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you.
Hello Zhivko,
does the new product idea refer to the highlighting or the replace function?
Regards
Hello,
I am just checking if there is anything else I can do for you.
I have been looking into it and the reason for the CellValuePresenters to be null is that the XamDataGrid is virtualizing its visual elements and creates visual elements only for the records and cells that are in view. When you try to get a CellValuePresenter for a cell that is not in view, CellValuePresenter.FromCell will return null.
I modified the previous sample application and change the approach to achieve the required functionality. In the sample I created style for CellValuePresenter to set the background color of matched cells. In it, I used MultiBinding to bind the Background of the CellValuePresenter to the Record, the Field and also the Tag of the XamDataGrid. In the converter of the MultiBinding, I am using the Record and the Field of the CellValuePresnter to get the Cell and based on its Tag property to set return the appropriate brush for the background. The third binding in the MultiBinding (the binding to the XamDataGrid's Tag) is used to trigger the whole MultiBinding when typing in the search TextBox. I modified the code behind of UserControl and added a list<Cell> 'cellResults' to store the cells. In the event handler of TextChanged event I loop all cells and for these cells that match with the criteria for searching I set the tag property and it to 'cellResults' collection.
The sample application is showing a custom approach that can be used as a guideline for implementing the functionality that you are looking for. Since implementing such custom features is outside of the scope of the developer support (you can read more details here: http://ko.infragistics.com/support/support-policies), if you need any help implementing such custom functionalities, I can suggest contacting our consulting team.
Thanks for choosing Infragistigs.
thanks for your help.
I'm searching in the whole grid, so I tried to reset the cell colors like that:
private void ResetAllCellColors() { foreach (DataRecord record in _grid.Records) { foreach (Cell cell in record.Cells) { var cellPresenter = CellValuePresenter.FromCell(cell); if (cellPresenter != null) cellPresenter.Background = Brushes.Transparent; } } }
Unfortunaltely cellPresenter is very often null (especially with high column numbers). What am I missing?
Edit
It seems to have something to do with the rendering of the grid. If I scroll fully to the right before my search, everything works as expected.
How can I fix this?
Hello Swanapil,
I have been looking into it. Currently the replace functionality that you want to achieve is determined to be a Product idea.
About highlighting: I modified the sample from the forum thread that you have provided to show you how you can achieve this functionality. Basically in the event handler of TextChanged event I used CellValuePresenter to change the background of the these cells that match with the criteria for searching. Also at the beginning of this event I set the background to transparent as default color, to reset it when changing the search criteria. I handled the LostFocus event of the textbox and in the event handler I set the background of cells back to the transparent.
Please let me know if you need any further assistance on this matter.