sergio_chile
2015-07-07T06:43:43Z
Hi. my first time using this control and i can't populate my grid... please help me....

(I'm adding controls at runtime.....only programmatically)

this is my load event:
Try
    Me.IGrid1.BeginUpdate()

    Me.IGrid1.FillWithData(ConnHelper.ExecuteDataTable("select * from [Production].[ProductSubCategory]"), False)  // true or false? here or at the end?


    'the combobox
    Dim cboProductos = New iGDropDownList
    Dim tabla As DataTable = ConnHelper.ExecuteDataTable("select * from [Production].[ProductCategory]")

    cboProductos.FillWithData(tabla, "ProductCategoryID", "Name")
    Me.IGrid1.Cols(1).CellStyle.DropDownControl = cboProductos
    Me.IGrid1.Cols(1).CellStyle.ValueType = GetType(String)         

    Me.IGrid1.Cols.AutoWidth()

Catch ex As Exception
    MsgBox(ex.Message)
Finally

    Me.IGrid1.EndUpdate()

End Try

this is what I get :


1.jpg

Click to View Image166 View(s)

2.jpg

Click to View Image163 View(s)



but, i need to show the "Name" field from database. not the "ID"
Igor/10Tec
2015-07-07T10:12:58Z
When you issue the first FillWithData for the whole grid, iGrid has no information to link your ID's to the combo list items. Thus you need to define your column set and cboProductos before the IGrid1.FillWithData call. After that, issue the overloaded version of the FillWithData method with the useCurColSet parameter set to True to use the defined column set.
sergio_chile
2015-07-07T14:14:13Z
ok.

Public Sub New()
        ' Llamada necesaria para el diseñador.
        InitializeComponent()
        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        With Me.IGrid1
            .GroupBox.Visible = True
            .Cols.Add("Columna uno")
            .Cols.Add("Columna dos")
            .Cols.Add("Columna tres")
            .Cols.Add("Columna cuatro")
            .Cols.Add("Columna cinco")
        End With
    End Sub

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load


        Try
            Me.IGrid1.BeginUpdate()

            'fill the combobox
            Dim cboProductos = New iGDropDownList

            Dim tabla As DataTable = ConnHelper.ExecuteDataTable("select * from [Production].[ProductCategory]")

            cboProductos.FillWithData(tabla, "ProductCategoryID", "Name")
            Me.IGrid1.Cols(1).CellStyle.DropDownControl = cboProductos
            Me.IGrid1.Cols(1).CellStyle.ValueType = GetType(String)

            'whole the grid
            Me.IGrid1.FillWithData(ConnHelper.ExecuteDataTable("select * from [Production].[ProductSubCategory]"), True)

            Me.IGrid1.Cols.AutoWidth()

        Catch ex As Exception
            MsgBox(ex.Message)
        Finally

            Me.IGrid1.EndUpdate()

        End Try
    End Sub


and this is the result:
1.jpg

Click to View Image162 View(s)

Igor/10Tec
2015-07-07T14:23:26Z
The keys of the column you create should correspond to the field names in your data source. Here is the pertinent excerpt from the manual:

Quote:

The FillWithData method provides you with an ability to load not all the columns from the specified data source to the grid. In this case you need to create the required set of columns in the grid first and then invoke the corresponding overloaded version of the method in which the second parameter, useCurColSet, is set to True. The column keys of the existing columns in iGrid will be used as field names in the specified data source. If a column does not have a string key or it does not correspond to any column in the data source, the column will remain empty.

sergio_chile
2015-07-07T14:48:45Z
Thank you very much....


I needed include the property "Key"



With Me.IGrid1
            .GroupBox.Visible = True
            .Cols.Add("Columna ID").Key = "ProductSubcategoryID"
            .Cols.Add("Categoría ID").Key = "ProductCategoryID"
            .Cols.Add("Nombre").Key = "Name"
            .Cols.Add("rowguid").Key = "rowguid"
            .Cols.Add("Fecha modificación").Key = "ModifiedDate"
        End With
Igor/10Tec
2015-07-07T14:53:31Z
You can also use this overload version of the iGColCollection.Add method:

Public Function Add ( _
	key As String, _
	text As String _
) As iGCol

So your code could look like this:

.Cols.Add("ProductSubcategoryID", "Columna ID")
.Cols.Add("ProductCategoryID", "Categoría ID")
.Cols.Add("Name", "Nombre")
.Cols.Add("rowguid", "rowguid")
.Cols.Add("ModifiedDate", "Fecha modificación")
sergio_chile
2015-07-07T15:29:58Z
I would like to ask another question...

how i could init the form with this?
2.jpg

Click to View Image149 View(s)

Igor/10Tec
2015-07-08T10:28:58Z
If you need to group the grid from code, here is your code:

' Add the column to group by to the group object
iGrid1.GroupObject.Add("Categoría ID")

' Perform actual grouping
iGrid1.Group()
Users browsing this topic