我正在尝试将光标聚焦在Qdatagrid的过滤器文本框中,其中刷新了页面.我怎样才能做到这一点



这是我的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;

然后我正在创建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);

在刷新页面时,我可以如何将光标自动聚焦到"第一个"的文本框。

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

在qcuubed中,qform类的form_create方法在页面刷新过程中执行。(form_run在刷新和ajax调用上执行)。

看起来您正在使用QCUBED的较旧V2,因此可以在定义datagrid和列后在form_create函数中执行此操作:

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

$ filterID应该是第一个字段的JavaScript ID。通过查看HTML来进行双重检查。$这是表单对象。

可以像这样轻松完成只需将col的名称更改为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);

然后,

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

相关内容

  • 没有找到相关文章

最新更新