2012-10-14 29 views
0

AjaxCrud有一個問題。創建關係時,將使用輸入文本字段創建搜索。在ajaxCrud的addAjaxFilterBox defineRelationship字段上搜索

因此,如果您與另一個表有關係,則無法使用外表的描述字段。您必須使用外鍵的ID進行搜索。 失敗

那麼,我的用戶甚至不知道有ID字段。

所以我真的需要使用外鍵表值來更改那些帶有字段的輸入文本。

我的解決方案就在下面。

回答

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){ 近l ine 1156.

它通過關係數組並創建基於查詢結果的選定內容。

如果此人解決了您的問題,請投票。分享,如果你有更好的解決方案。