Python Forum
UI ComboBox in DatagridColumn
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UI ComboBox in DatagridColumn
#1
Hello,

I crate a DataGrid and I want to insert for every row in the third column a ComboBox. I am so far til now:

def getUIContent():
   my_toolProperty = sdk.ToolPropertyContainer()   

   # Define UI
   my_toolProperty.ToolPropertyContent = getCustomToolPropertyContent()
   
   # Update Grid
   UpdateDataGridData()
   
   return my_toolProperty
def getCustomToolPropertyContent():

   # Create a Grid
   my_Grid = WPFControls.Grid()

   # Add 1 Row and One Column
   my_Grid.RowDefinitions.Add(WPFControls.RowDefinition())
   my_Grid.ColumnDefinitions.Add(WPFControls.ColumnDefinition())
  
   # Create a DataGrid
   global myDataGrid
   myDataGrid = WPFControls.DataGrid()
   
   # global myComboBox
   myComboBox = WPFControls.DataGridComboBoxCollumn()

   
   # Add the DataGrid to the Grid 
   my_Grid.Children.Add(myDataGrid)

   # Return the Grid   
   return my_Grid

# def UpdateData (it's only the Path of api / not important)

@apex_sdk.errorhandler
def UpdateDataGridView():

   # Retrieve grid results
   grid = sdk.getScriptFunctionReturnData()

   # Create table
   data_table = WPFData.DataTable("Contents")
   data_table.Columns.Add("Prename")
   data_table.Columns.Add("Last Name")
   
   # Add data to the table for each name
   parts = grid['Name']
   for name in names:      
      data_table.Rows.Add(part['prename'], part['lastname'])
   
   # Set the IetmsSource for the data grid to the DataTable 
   myDataGrid.ItemsSource = data_table.DefaultView
   # myDataGrid.ItemsSource = myComboBox     ??? 
   
   # Position the DataGrid in the first row, column of the Grid
   WPFControls.Grid.SetRow(myDataGrid, 0)
   WPFControls.Grid.SetColumn(myDataGrid, 0)
Reply
#2
Two things (1) a MRE (Minimal Reproducible Example) will help you get a faster answer -- aka if one can just copy and paste what you provided and run it the answers are much faster in coming and more accurate in their response.

(2) What are you using for your Gui -- Tkinter, PyQt, etc... this should be in your subject so that folks that are in the know about what you are asking about know that this is a item they can reply to
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] How can I sync Combobox index to other combobox index? nickzsche 2 2,332 Jan-03-2022, 12:29 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020