Harshith Cariappa
Harshith Cariappa

Reputation: 79

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'.

Upvotes: 1

Views: 69

Answers (3)

Harshith Cariappa
Harshith Cariappa

Reputation: 79

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();

Upvotes: 0

spekary
spekary

Reputation: 438

In QCubed, the Form_Create method of the QForm class executes during a page refresh. (Form_Run executes on both refreshes and ajax calls).

It looks like you are using the older v2 of QCubed, so you can do this in your Form_Create function after defining your datagrid and columns:

$filterId = 'ctl' . $this->dtgContent->ControlId . 'flt0';
$this->GetControl($filterId)->Focus();

$filterId should be the javascript id of the First field. Double check by looking at the html. $this is the form object.

Upvotes: 0

Rushil K. Pachchigar
Rushil K. Pachchigar

Reputation: 1321

<script>
     $( "#target" ).focus();
</script>

Upvotes: 0

Related Questions