0

AjaxCrudには1つの問題があります。リレーションシップを作成すると、入力テキストフィールドを使用して検索が作成されます。

したがって、別のテーブルとの関係がある場合、外部テーブルの説明フィールドを使用することはできません。外部キーのIDを使用して検索する必要があります。不合格

ええと、私のユーザーはIDフィールドがあることすら知りません。

したがって、外部キーテーブルの値を使用して、これらの入力テキストをフィールドで変更する必要がありました。

私の解決策はすぐ下にあります。

4

1 に答える 1

1

ajaxCRUD.class.phpを変更しました

行1191の近く、間

$top_html .= "</select>\n";
            } and `else{
                $custom_class = "";
                if ($this->display_field_with_class_style[$filter_field] != '') {`

私はこのコードを挿入しました:

else
            if (is_numeric($found_category_index))
            {
                $category_field_name = $this->category_field_array[$found_category_index];
                $category_table_name = $this->category_table_array[$found_category_index];
                $category_table_pk   = $this->category_table_pk_array[$found_category_index];
                $order_by = '';
      if ($this->category_sort_field_array[$found_category_index] != ''){
          $order_by = " ORDER BY " . $this->category_sort_field_array[$found_category_index];
      }

      $whereclause  = '';
      if ($this->category_whereclause_array[$found_category_index] != ''){
          $whereclause = $this->category_whereclause_array[$found_category_index];
      }

                $dropdown_array = q("SELECT $category_table_pk, $category_field_name FROM $category_table_name $whereclause $order_by");

                $top_html .= "<br><select name=\"$filter_field\" onChange=\"filterTable(this, '" . $this->db_table . "', '$filter_field', '$extra_query_params');\">";
                $top_html .= "<option value=\"\">==Select==</option>\n";

                foreach ($dropdown_array as $dropdown)
                {
          $dropdown_value = $dropdown[$this->category_table_pk_array[$found_category_index]];
          $dropdown_text  = $dropdown[$this->category_field_array[$found_category_index]];
          $top_html .= "<option value=\"$dropdown_value\" >$dropdown_text</option>\n";
      }

                $top_html .= "</select>\n";

            }

そして、私はこの行を含めました$found_category_index = array_search($filter_field, $this->db_table_fk_array);

この後:foreach ($this->ajaxFilter_fields as $filter_field){ 1156行目近く。

リレーションシップ配列を通過し、クエリ結果に基づいて選択されたものを作成します。

これで問題が解決したかどうか投票してください。より良い解決策があれば共有してください。

于 2012-10-14T00:32:25.157 に答える