phpqcubed

I am trying to focus my cursor in the filter textbox of QDataGrid where the page is refreshed. how can i do this


This is my QDataGrid

    $this->content = new QDataGrid($this, 'Dashboard');
    $this->dtgContent->UseAjax = true;
    $this->dtgContent->ShowFilter = true;
    $this->dtgContent->RowActionParameterHtml = '<?= $_ITEM->FileNum ?>';
    $this->dtgContent->SetDataBinder('BindDataGrid_Content', $this);
    $this->dtgContent->Paginator = new QPaginator($this->dtgContent);
    $this->dtgContent->ItemsPerPage = 15;
    $this->dtgContent->SortColumnIndex = 5;
    $this->dtgContent->SortDirection = true;

Then i am creating 2 QDataGridColumns

    $col = new QDataGridColumn('First', '<?= $_CONTROL->ParentControl->renderFirst($_ITEM) ?>');
    $col->HtmlEntities = false;
    $col->OrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin);
    $col->ReverseOrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, false);
    $col->Filter = QQ::Like(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, null);
    $col->FilterType = QFilterType::TextFilter;
    $col->FilterPrefix = $col->FilterPostfix = '%';
    $col->Width = 170;
    $this->dtgContent->AddColumn($col);

    $col = new QDataGridColumn('Year', '<?= $_ITEM->CfgfilevehicleAsFileNum->VehicleIdObject->Year ?>');
    $col->FilterType = QFilterType::TextFilter;
    $col->Filter = QQ::Like(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Year, null);
    $col->FilterPostfix = $col->FilterPrefix = '%';
    $col->OrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Year);
    $col->ReverseOrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Year, false);
    $col->Width = 50;
    $this->dtgContent->AddColumn($col);

On refreshing the page how can i focus the cursor automatically to the textbox of 'First'.


Solution

  • It can be done easily like this, just change the name col to col1

    $col1 = new QDataGridColumn('First', '<?= $_CONTROL->ParentControl->renderFirst($_ITEM) ?>');
    $col1->HtmlEntities = false;
    $col1->OrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin);
    $col1->ReverseOrderByClause = QQ::OrderBy(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, false);
    $col1->Filter = QQ::Like(QQN::Appfile()->CfgfilevehicleAsFileNum->VehicleIdObject->Vin, null);
    $col1->FilterType = QFilterType::TextFilter;
    $col1->FilterPrefix = $col->FilterPostfix = '%';
    $col1->Width = 170;
    $this->dtgContent->AddColumn($col1);
    

    then,

        $ctrFilter = $this->dtgContent->GetFilterControl($col1);
        $ctrFilter->Focus();