Hi,
I have a situation where after user has typed the data in the first column and pressed tab, a query will be performed and the resulting data should fill the rest of the columns.
Col 1 col2
+-----------------|+------------|---------------|--------------------|
12345 & tab Should populate rest
Thanks.
Hello Joy,
Thank you for contacting Infragistics Developer Support.
I am not sure how you bind your data in the grid and how you execute your queries against the data source/data base so I will provide you one of the suggestions that came to my mind.
One of the possible solution in order to get a data from a dataset(or a database) source is to write a LINQ query. Using the value of the first column helps the query to find the rest of the data from the source and attach it to the data source of the UltraGrid. You could find more information about Querying DataSets here:
http://msdn.microsoft.com/en-us/library/bb399358%28v=vs.110%29.aspx
I’ve implemented this suggestion in a simple sample, and you could run and evaluate it, please see attached zip.
Please let me know if my assumptions are wrong, or the suggested implementation is not appropriate for your scenario. Please add more details about the datasouce/database you are using and how you build and execute the query in that is build based on the first column.
Please let me know if you have any further questions.
Hi Atanas, Thanks for your solution. I ran your zipped up app. and it is prtty much what I was looking for thank you very very much. There is one small thing I wanted to ask. Once the row is filled can we move the focus to the new row? Also, the add row seems to contain the last appoinment id, can we also get rid of that?
It seems like in your sample, it is adding a new row. Not appending to the row you just typed the AppoinmentId in.
I am also adding my databinding process.
I have a model PurchaseAdviceWizardDataView I also have a BindingList<PurchaseAdviceWizardDataView>(); I then do this this.gridLoanResult.SetDataBinding(_context.PurchaseAdviceListView, null);
It seems like unless I do the last line in my case I do not get the result view.
I have managed to modify my sample. So, now once the row is filled the focus is moved to the new row. I also removed the row that contained the last id. As you have noticed in my sample a new row is added with the information that was taken from the data source/data base. The LINQ query uses the information you have provided in the first column and finds the rest of the data from the data source/data base. After that that information is added to the UltraGrid as a new row of the data source attached to the grid. Once the new row is added to the UltraGrid’s data source the added row is visualized in the grid. That’s why you need
this.gridLoanResult.SetDataBinding(_context.PurchaseAdviceListView, null);
in your project.
I am sending you the modified sample, and you could run and evaluate it, please see attached zip.
I hope that this will help you.
Please do not hesitate to contact me if you have any further question.
Hi Atanas,
Thank you so very much for the sample. I implemented the followings. Since you are using DataTable and I am using BindingList and also I want to keep the behavior of the Delete function (would not like to suppress the prompt). But I have a question regarding a behavior.
In the below example. I have a function called clean. Where i go through the list and remove the ones that are null. If I don't do that, then I get the extra rows. I am assuming the empty rows that you are deleting in your code are the ones. So, the grid is somehow adding those the data source? Since I am not. I am dong only one add just for 1 row as far as I can say. So where are these getting added?
Thanks so much again.
private void grid_KeyDown(object sender, KeyEventArgs e)
{
var arow = this.grid.ActiveRow.Index; // saving the active row
if (e.KeyData == Keys.Tab && this.grid.ActiveCell.Column.ToString().Equals("num"))
var num = this.grid.ActiveCell.Text.Trim();
var data = _context.Services.GetSingle(num);
_context.Clean(); // need to clean the list, since it seems like it automatically adds the row. so what happens is,
// if i don't clean the list for empty data, the binding keeps adding an
// extra row each time. this probably replaces the delte you used.
_context.ListView.Add(data);
this.grid.SetDataBinding(_context.ListView, null);
this.EditCell(arow, mField);
}
//in _context
public void Clean()
foreach (DataView dv in this.ListView.ToList())
if (string.IsNullOrEmpty(dv.num))
this.ListView.Remove(dv);
I forgot to add the following:
and what editCell does is it puts the focus on the 3rd col for the active row. I realized later that I don't need to focus to the new row rather need to focus to the 3rd col of the same row.
private void FocusCell(int row, int col)
this.grid.ActiveCell = grid.Rows[row].Cells[col];
this.grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.EnterEditMode, false, false);
I can’t say for sure from the provided code why these empty rows are added to your UltraGrid. But, for the ‘Clean’ method I recommend you instead of going through the list just to delete the last active row. I assume that this row is the empty one. I modify my sample changing my data source to BindingList to be as much as closer to your scenario and I also implement the Clean and FocusCell methods.
If the sample doesn’t help you to fix the issue please modify it to reproduce your issue, so I will be able to investigate this on my side.
I am waiting for your feedback.
this.ultraCombo1.SyncWithCurrencyManager = true;
Hope you are doing well.
I am trying to use UltraCombo, which i believe is a part of the grid family. When I used a regular windows combobox I was able to bind it with a BindingList. I also bound few other text controls with that and when I selected new values in the regular combobox it also changed all the values in all other controls that were bound to the same BindingList.
But, when I used the UltraCombo (with multicolums) selecting a row does not change the other controls. What is the way to achive this with UltraCombo?
Thanks for the reply.
Do not hesitate to contact me if you have any additional questions.
Thank you for using Infragistics Components.
Sorry for the long delay. I have been away and just getting back. I think for what you have given me enough to solve the issues I had. I will surely post any updates I may have. Your informations greatly helped.
Thanks again.
I am just checking about the progress of this issue. Let me know If you need my further assistance on this issue?