How to Get Dropdown in grid to update programmatically

This should’ve been easy. I am setting a field in a customization on a button click. I’m working in Mass Issue to Mfg form. When I set the From Warehouse to the value I want, the description stays the same as it was prior to me changing… but the bin updates just fine. Then, if I click the warehouse drop-down, but don’t select anything… it updates the description to the new warehouse I set it to. Any other rows I hover over after that will also update to the new description. What am I missing in my customization to make the description update so the user can see that it’s changed.

	private void btnCopyAll_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		string warehouse = edvCallContextBpmData.dataView[edvCallContextBpmData.Row]["ShortChar01"].ToString();
		string bin = edvCallContextBpmData.dataView[edvCallContextBpmData.Row]["ShortChar02"].ToString();
		for (int i = 0; i < edvMtl.dataView.Count; i++)
		{
			edvMtl.dataView[i].BeginEdit();
			edvMtl.dataView[i]["Warehouse"] = warehouse;
			//edvMtl.dataView[i]["WarehouseDescription"] = "Desc";
			edvMtl.dataView[i]["BinNum"] = bin;
			edvMtl.dataView[i]["RowMod"] = "U";
			edvMtl.dataView[i].EndEdit();
		}
		oTrans.NotifyAll();
	}

Did you remember to add that dataview to otrans?

1 Like

Yes, that data view was already there. I just created an instance of it in my code so I could set values.

Did you try a refresh on the control?

1 Like

I did. I tried manually setting the description along with the code but that doesn’t seem to have any effect either. I did see in the trace that there is a method that fires when I change the warehouse… something like OnWarehouseChange or something. Do you think I need to manually call that using an adapter or something?

Well your description was unclear on what “description” was.

What field is the description control bound to?

So it’s a grid that is editable and the column for “From Warehouse” is bound to the Warehouse field on Mtl view. But it’s a drop-down that displays the description (which I believe is WarehouseDescription field) while the actual DB table stores the code value.


image

Had trouble with grids before, try this:

		var ds = epiUltraGridC1.DataSource;
		
		epiUltraGridC1.DataSource = "";

		epiUltraGridC1.Refresh();
		
		epiUltraGridC1.DataSource = ds;
		
		epiUltraGridC1.Refresh();
1 Like

That did get the result to look proper when done… however, my personalization was lost during the refresh… so the columns I had slid over to make it easier to work with went back to their default position. That’s odd…

It’s like I need to refresh that specific column in the grid. I’ll dig through the infragistics docs and see if I can find something like that. The epiDataView updates like I want… it’s something with the UI/grid that is not displaying the EDV properly.

You can, I don’t remember how off the top of my head.

:exploding_head:

The whole personalization, or just the grid?

Did you drag it around and not save the layouts before testing?

It didn’t delete the personalization. It just reverted back to default column layout. I know that it’s stuck there because everytime I re-open the form and try something new my columns remain where I dragged them. I also tried refreshing the UltraGridRow and Cell… lol. It’s so weird. The UltraGridCell value is the correct value for both warehouse and warehouse description when I check it during my button click. But the UI does not visually represent what the underlying data is.

and a

oTrans.NotifyAll();
yourGrid.Refresh();

won’t do it eh?

just spitballin’, but maybe drop this first refresh.

		var ds = epiUltraGridC1.DataSource;
		
		epiUltraGridC1.DataSource = "";

		//epiUltraGridC1.Refresh();
		
		epiUltraGridC1.DataSource = ds;
		
		epiUltraGridC1.Refresh();

Nope. I took your suggestions from my last little project and was eager to apply them to this one thinking I had it all figured out. I’ll spend some time trying to figure out how to not lose the personalization and then use your suggestion from above…

I just found out you can save the grid layout to a string.

Should be able to save it before refresh, and restore after.

That’s kind of what I was looking for. I tried DisplayLayout on the grid control and it said it’s read only. I’ll keep digging.

Pardon me, stream, not string.

What’s frustrating the most though… if I click the arrow to drop down the list, the description updates. Then, if I simply hover over any other rows, the description updates as I do so. Then, forever more, the fields update like you’d expect when I change the underlying value. It’s just getting it to get off the first warehouse it was on that is stubborn.

I got it, might be gross, but it works.