public void inicializar() {
    // campos
    FieldDef[] fd =
        new FieldDef[] {
          new IntegerFieldDef("comTrocaProdutoId"),
          new IntegerFieldDef("comTroca.comTrocaId"),
          new IntegerFieldDef("comTroca.empEmpresa.empEmpresaId"),
          new StringFieldDef("comTroca.empEmpresa.empEntidade.empEntidadeNome1"),
          new StringFieldDef("prodProduto.empFornecedor.empEntidade.empEntidadeNome1"),
          new IntegerFieldDef("prodProduto.prodProdutoId"),
          new StringFieldDef("comTrocaProdutoBarra"),
          new StringFieldDef("prodProduto.prodProdutoDescricao"),
          new StringFieldDef("prodProduto.prodProdutoReferencia"),
          new DateFieldDef("comTroca.comTrocaData"),
          new FloatFieldDef("comTrocaProdutoQuantidade"),
          new IntegerFieldDef("prodEmbalagem.prodEmbalagemId"),
          new StringFieldDef("prodEmbalagem.prodEmbalagemNome"),
          new FloatFieldDef("comTrocaProdutoValor"),
          new FloatFieldDef("comTrocaProdutoTotal"),
          new IntegerFieldDef("comTrocaProdutoOrdem")
        };
    campos = new RecordDef(fd);

    // colunas
    ColumnConfig ccId = new ColumnConfig(OpenSigCore.i18n.txtCod(), "comTrocaProdutoId", 75, true);
    ColumnConfig ccTrocaId =
        new ColumnConfig(
            OpenSigCore.i18n.txtCod() + " - " + OpenSigCore.i18n.txtTroca(),
            "comTroca.comTrocaId",
            100,
            true);
    ccTrocaId.setHidden(true);
    ColumnConfig ccEmpresaId =
        new ColumnConfig(
            OpenSigCore.i18n.txtCod() + " - " + OpenSigCore.i18n.txtEmpresa(),
            "comTroca.empEmpresa.empEmpresaId",
            100,
            true);
    ccEmpresaId.setHidden(true);
    ColumnConfig ccEmpresa =
        new ColumnConfig(
            OpenSigCore.i18n.txtEmpresa(),
            "comTroca.empEmpresa.empEntidade.empEntidadeNome1",
            100,
            true);
    ccEmpresa.setHidden(true);
    ColumnConfig ccFornecedor =
        new ColumnConfig(
            OpenSigCore.i18n.txtFornecedor(),
            "prodProduto.empFornecedor.empEntidade.empEntidadeNome1",
            200,
            true);
    ColumnConfig ccProdId =
        new ColumnConfig(
            OpenSigCore.i18n.txtCod() + " - " + OpenSigCore.i18n.txtProduto(),
            "prodProduto.prodProdutoId",
            100,
            true);
    ccProdId.setHidden(true);
    ColumnConfig ccBarra =
        new ColumnConfig(OpenSigCore.i18n.txtBarra(), "comTrocaProdutoBarra", 100, true);
    ColumnConfig ccProduto =
        new ColumnConfig(
            OpenSigCore.i18n.txtProduto(), "prodProduto.prodProdutoDescricao", 250, true);
    ColumnConfig ccReferencia =
        new ColumnConfig(OpenSigCore.i18n.txtRef(), "prodProduto.prodProdutoReferencia", 100, true);
    ColumnConfig ccData =
        new ColumnConfig(OpenSigCore.i18n.txtData(), "comTroca.comTrocaData", 75, true, DATA);
    ColumnConfig ccEmbalagemId =
        new ColumnConfig(
            OpenSigCore.i18n.txtCod() + " - " + OpenSigCore.i18n.txtEmbalagem(),
            "prodEmbalagem.prodEmbalagemId",
            100,
            true);
    ccEmbalagemId.setHidden(true);
    ccEmbalagemId.setFixed(true);
    ColumnConfig ccEmbalagem =
        new ColumnConfig(
            OpenSigCore.i18n.txtEmbalagem(), "prodEmbalagem.prodEmbalagemNome", 75, true);
    ColumnConfig ccOrdem =
        new ColumnConfig(OpenSigCore.i18n.txtOrdem(), "comTrocaProdutoOrdem", 100, true);
    ccOrdem.setHidden(true);

    // somarotios
    SummaryColumnConfig ccQuantidade =
        new SummaryColumnConfig(
            SummaryColumnConfig.SUM,
            new ColumnConfig(
                OpenSigCore.i18n.txtQtd(), "comTrocaProdutoQuantidade", 50, true, NUMERO),
            NUMERO);
    SummaryColumnConfig ccValor =
        new SummaryColumnConfig(
            SummaryColumnConfig.SUM,
            new ColumnConfig(
                OpenSigCore.i18n.txtValor(), "comTrocaProdutoValor", 75, true, DINHEIRO),
            DINHEIRO);
    SummaryColumnConfig ccTotal =
        new SummaryColumnConfig(
            SummaryColumnConfig.SUM,
            new ColumnConfig(
                OpenSigCore.i18n.txtTotal(), "comTrocaProdutoTotal", 75, true, DINHEIRO),
            DINHEIRO);

    BaseColumnConfig[] bcc =
        new BaseColumnConfig[] {
          ccId,
          ccTrocaId,
          ccEmpresaId,
          ccEmpresa,
          ccFornecedor,
          ccProdId,
          ccBarra,
          ccProduto,
          ccReferencia,
          ccData,
          ccQuantidade,
          ccEmbalagemId,
          ccEmbalagem,
          ccValor,
          ccTotal,
          ccOrdem
        };
    modelos = new ColumnModel(bcc);

    if (UtilClient.getAcaoPermitida(funcao, ComandoPermiteEmpresa.class) == null) {
      filtroPadrao =
          new FiltroObjeto(
              "comTroca.empEmpresa",
              ECompara.IGUAL,
              new EmpEmpresa(Ponte.getLogin().getEmpresaId()));
    }
    super.inicializar();
  }
  /** {@inheritDoc} */
  @Override
  public void init() {

    String entityViewUrl = "/crmsfa/control/viewAccount?partyId={0}";
    StringFieldDef idDefinition = new StringFieldDef(PartyLookupConfiguration.INOUT_PARTY_ID);

    makeLinkColumn(UtilUi.MSG.crmContactId(), idDefinition, entityViewUrl, true);
    makeLinkColumn(
        UtilUi.MSG.crmAccountName(),
        idDefinition,
        new StringFieldDef(PartyLookupConfiguration.INOUT_FRIENDLY_PARTY_NAME),
        entityViewUrl,
        true);
    makeColumn(UtilUi.MSG.partyCity(), new StringFieldDef(PartyLookupConfiguration.INOUT_CITY));
    makeColumn(
        UtilUi.MSG.crmPrimaryEmail(), new StringFieldDef(PartyLookupConfiguration.INOUT_EMAIL));
    makeColumn(
        UtilUi.MSG.crmPrimaryPhone(),
        new StringFieldDef(PartyLookupConfiguration.INOUT_FORMATED_PHONE_NUMBER));
    makeColumn(
        UtilUi.MSG.partyToName(), new StringFieldDef(PartyLookupConfiguration.INOUT_TO_NAME));
    makeColumn(
        UtilUi.MSG.partyAttentionName(),
        new StringFieldDef(PartyLookupConfiguration.INOUT_ATTENTION_NAME));
    makeColumn(
        UtilUi.MSG.partyAddressLine1(), new StringFieldDef(PartyLookupConfiguration.INOUT_ADDRESS));
    makeColumn(
        UtilUi.MSG.partyAddressLine2(), new StringFieldDef(PartyLookupConfiguration.OUT_ADDRESS_2));
    makeColumn(UtilUi.MSG.partyState(), new StringFieldDef(PartyLookupConfiguration.INOUT_STATE));
    makeColumn(
        UtilUi.MSG.partyCountry(), new StringFieldDef(PartyLookupConfiguration.INOUT_COUNTRY));
    makeColumn(
        UtilUi.MSG.partyPostalCode(),
        new StringFieldDef(PartyLookupConfiguration.INOUT_POSTAL_CODE));
    makeColumn(
        UtilUi.MSG.crmPostalCodeExt(),
        new StringFieldDef(PartyLookupConfiguration.OUT_POSTAL_CODE_EXT));

    // add last column if logged in user has required permission
    deleteColumnIndex = getCurrentColumnIndex();
    if (hasAccountsRemoveAbility()) {
      ColumnConfig config =
          makeColumn(
              "",
              new Renderer() {
                public String render(
                    Object value,
                    CellMetadata cellMetadata,
                    Record record,
                    int rowIndex,
                    int colNum,
                    Store store) {
                  return Format.format(
                      "<img width=\"15\" height=\"15\" class=\"checkbox\" src=\"{0}\"/>",
                      UtilUi.ICON_DELETE);
                }
              });
      config.setWidth(26);
      config.setResizable(false);
      config.setFixed(true);
      config.setSortable(false);

      addGridCellListener(
          new GridCellListenerAdapter() {
            private final String actionUrl = "/crmsfa/control/removeContactFromAccountAJX";

            /** {@inheritDoc} */
            @Override
            public void onCellClick(GridPanel grid, int rowIndex, int colindex, EventObject e) {
              if (colindex == AccountsSublistView.this.deleteColumnIndex) {
                String accountPartyId = getStore().getRecordAt(rowIndex).getAsString("partyId");
                RequestBuilder request = new RequestBuilder(RequestBuilder.POST, actionUrl);
                request.setHeader("Content-type", "application/x-www-form-urlencoded");
                request.setRequestData(
                    Format.format(
                        "partyId={0}&contactPartyId={0}&accountPartyId={1}",
                        AccountsSublistView.this.contactPartyId, accountPartyId));
                request.setCallback(
                    new RequestCallback() {
                      public void onError(Request request, Throwable exception) {
                        // display error message
                        markGridNotBusy();
                        UtilUi.errorMessage(exception.toString());
                      }

                      public void onResponseReceived(Request request, Response response) {
                        // if it is a correct response, reload the grid
                        markGridNotBusy();
                        UtilUi.logInfo(
                            "onResponseReceived, response = " + response,
                            MODULE,
                            "ContactListView.init()");
                        if (!ServiceErrorReader.showErrorMessageIfAny(response, actionUrl)) {
                          getStore().reload();
                          loadFirstPage();
                        }
                      }
                    });

                try {
                  markGridBusy();
                  UtilUi.logInfo("posting batch", MODULE, "ContactListView.init()");
                  request.send();
                } catch (RequestException re) {
                  // display error message
                  UtilUi.errorMessage(e.toString(), MODULE, "ContactListView.init()");
                }
              }
            }
          });
    }

    configure(
        PartyLookupConfiguration.URL_FIND_ACCOUNTS,
        PartyLookupConfiguration.INOUT_PARTY_ID,
        SortDir.ASC);

    // by default, hide non essential columns
    setColumnHidden(PartyLookupConfiguration.INOUT_PARTY_ID, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_STATE, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_COUNTRY, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_TO_NAME, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_ATTENTION_NAME, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_ADDRESS, true);
    setColumnHidden(PartyLookupConfiguration.OUT_ADDRESS_2, true);
    setColumnHidden(PartyLookupConfiguration.INOUT_POSTAL_CODE, true);
    setColumnHidden(PartyLookupConfiguration.OUT_POSTAL_CODE_EXT, true);
  }