Home > Net >  Required Column not showing as required from UI
Required Column not showing as required from UI

Time:01-27

I have datacolumns that are marked as required in database objects that do not allow null values. This works fine when the user manually inserts a record from the UI. All required columns show up with a red exclamation next to them and users are unable to save until all required columns have been populated.

Issue I ran into is when attempting to insert records dynamically using a toolclick action. The code works as expected and adds records to the child pane and even prevents a user from saving if one of the required columns are not populated. However, the columns are not showing up as required like they would when manually inserting row from UI. Is there a way to get the red exclamation to show up like it would when manually inserting the record?

public UiEventResult ToolClick_Default_Valuation_Rows_After_1()
{
//active row in UI view that toolclick will be associated with
UltraGridRow ultraGridRow = _view.ViewGrids["view"].ActiveRow;

DataRow newDataRow;

newDataRow = _view.DataSource.Tables["table"].NewRow();
newDataRow["column"] = DBNull.Value;
_view.DataSource.Tables["table"].Rows.Add(newDataRow);       

return new UiEventResult(EventStatus.Continue);
}

CodePudding user response:

It's depend of the UltraGrid.UpdateMode property value. By default it set to UpdateMode.OnRowChangeOrLostFocus. Therefore, to raise the data validation process after adding a new row to the DataSource programmatically set the UltraGrid.UpdateMode to include UpdateMode.OnUpdate flag:

private void Form1Load(object sender, EventArgs e)
{
    InitializeForm();

    // Data binding.
    ultraGrid1.DataSource = /* data source */; 
 
    ultraGrid1.UpdateMode |= UpdateMode.OnUpdate;
}

CodePudding user response:

public UiEventResult InitView_1()
    {
        UltraGrid ultraGrid1 = _view.ViewGrids["view"];
        ultraGrid1.DataSource = _view.DataSource.Tables["table"];
        ultraGrid1.UpdateMode |= UpdateMode.OnUpdate;
        
        return new UiEventResult(EventStatus.Continue);
    }
  •  Tags:  
  • Related