Subscribe

UiPath Activities

The UiPath Activities Guide

Customizing Columns Width

Overview


Tables in your form sometimes need wider or narrower columns, rather than columns with the same width. You can set a custom width for tables in Edit Grid and Data Grid components.

Tutorial


The next tutorial provides steps on how to modify the width for Column3 in a table saved as myTable.

Building the Data Table

To create a table to use inside your form:

  1. Inside your workflow, add the Build Data Table activity.
  2. Click DataTable... . The Build Data Table wizard opens.
  3. Add the desired columns for your table and edit their properties.
    Make sure the columns name have no spaces or special characters, as you use these names to link the columns in the form through the Field Key component tab.
  1. Click OK to save the table.
  2. In the Properties panel > Output field of the Build Data Table activity, set a variable name for your table (for example, myTable ).
    You use this variable to bind the table to the form through the FormFieldsCollection property of the Create Form activity.

 

Binding the Data Table to your Form and Grid Components

To bind the data table to your form:

  1. Add the Create Form activity in your workflow.
  2. In the Properties panel > FormFieldsCollection field, click on the three dots menu (fa-ellipsis-v:) . The FormFieldsCollection wizard opens.
  3. Create an argument and link it to the previously created table using the variable (i.e., myTable). Set the argument Direction to In/Out and the Type to DataTable. Give a Name to your argument, for example table.
  1. Click OK.
    Make sure that GenerateInputFields box is unchecked.

To bind the data table to the Edit Grid or Data Grid component:

  1. Open the Form Designer from the Create Form activity.
  2. From the Data category, drag and drop a grid component (i.e., Edit Grid and/or Data Grid).
  3. In the Field Key tab of your grid, reference the table argument (i.e., table).
    The Field Key value is case sensitive.
  1. Add text components into your grid to replicate the columns in your table. Save each text component.
    For example, if your table has three columns called Column1, Column2, and Column3, drag and drop three text components into your grid, and make sure to use the column names from the table into the components Field Key tab.
    The Field Key value is case sensitive.
  1. Save the form.

 

Customizing Columns Width in Edit Grid Components

  1. Go to the Edit Grid Component settings .
  2. In the Templates tab > Header Template section, change the default generated code with the following template:
<div class="row">
      {% util.eachComponent(components, function(component) { %}
        {% if (displayValue(component)) { %}
        {% if (component.key=== 'Column3') { %}
              <div class="col-sm-8">
            {% } %}
            {% if (component.key !== 'Column3') { %}
              <div class="col-sm-2">
            {% } %}
          {{ component.label }}</div>
        {% } %}
      {% }) %}
    </div>
  1. In the Templates tab > Row Template section, change the default generated code with the following template:
<div class="row">
      {% util.eachComponent(components, function(component) { %}
       {% if (!component.hasOwnProperty('tableView') || component.tableView) { %}
            {% if (component.key=== 'Column3') { %}
              <div class="col-sm-8">
            {% } %}
            {% if (component.key !== 'Column3') { %}
              <div class="col-sm-2">
            {% } %}
            {{ getView(component, row[component.key]) }}
          </div>
        {% } %}
      {% }) %}
      {% if (!instance.options.readOnly && !instance.disabled) { %}
        <div class="col-sm-2">
          <div class="btn-group pull-right">
            <button class="btn btn-default btn-light btn-sm editRow"><i class="{{ iconClass('edit') }}"></i></button>
            {% if (!instance.hasRemoveButtons || instance.hasRemoveButtons()) { %}
              <button class="btn btn-danger btn-sm removeRow"><i class="{{ iconClass('trash') }}"></i></button>
            {% } %}
          </div>
        </div>
      {% } %}
    </div>

📘

Important!

  • Notice that you compare the component.key value to the exact name of the column, which is the same one used in the Field Key tab of each text component (step 4 in binding the data table to Edit Grid or Data Grid components).
  • UiPath Forms are using the Bootstrap 3 framework. The total width of the table is divided into 12 sections. Therefore, make sure that any division you make, it adds up to 12. In this example, two columns with col-sm-2 class take up 4 sections, leaving the remaining 8 for the third column (col-sm-8).

 

Customizing Columns Width in Data Grid Components

  1. Create a local CSS file with the desired column widths. In our example, the following template creates a wider Column3 (i.e., nth-child(3)):
.mygrid tbody>tr>:nth-child(1){ 
width: 70px;
}
.mygrid tbody>tr>:nth-child(2){ 
width: 15%;
}
.mygrid tbody>tr>:nth-child(3){ 
width: 60%;
}
  1. In the Properties panel > LocalCSSFilePath field of the Create Form activity, reference the previously created CSS file. For example,"/file://C:\User\Desktop\EditColumnWidth.css".
  2. In the Data Grid component > Display tab > Custom CSS Class field, enter the name of the CSS class (for example, mygrid).

Sample Workflow


To check the complete workflow or to have a future reference, download the XAML example below.

Updated about a month ago


Customizing Columns Width


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.