4 Replies - 261 Views - Last Post: 22 October 2017 - 07:17 AM Rate Topic: -----

#1 sadboys  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 10-August 15

Searching in the GridView doesn't show results

Posted 20 October 2017 - 10:23 AM

In my GridView when I search for "time_start" it doesn't show any results, but when I search for others like the 'id' it shows the id results.

Here's my Search Model

class TicketSearch extends Ticket
{
    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['id', 'escalation_level', 'check_in_id', 'employee_respond_id', 'department_id', 'category_id', 'employee_create_id'], 'integer'],
            [['request_title', 'status', 'time_start', 'time_end', 'time_alloted', 'desc'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        // bypass scenarios() implementation in the parent class
        return Model::scenarios();
    }

    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = Ticket::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'time_start' => $this->time_start,
            'time_end' => $this->time_end,
        //   'time_alloted' => $this->time_alloted,
        //  'escalation_level' => $this->escalation_level,
        //  'check_in_id' => $this->check_in_id,
            'employee_respond_id' => $this->employee_respond_id,
        //  'department_id' => $this->department_id,
        //  'category_id' => $this->category_id,
        //   'employee_create_id' => $this->employee_create_id,
        ]);

        $query->andFilterWhere(['like', 'request_title', $this->request_title])
            ->andFilterWhere(['like', 'status', $this->status])
            ->andFilterWhere(['like', 'desc', $this->desc]);

        return $dataProvider;
    }
}



Is This A Good Question/Topic? 0
  • +

Replies To: Searching in the GridView doesn't show results

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1829
  • View blog
  • Posts: 5,758
  • Joined: 15-January 14

Re: Searching in the GridView doesn't show results

Posted 20 October 2017 - 10:28 AM

What format is the time saved in, and what are you searching for? Is it the same format?
Was This Post Helpful? 0
  • +
  • -

#3 sadboys  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 10-August 15

Re: Searching in the GridView doesn't show results

Posted 20 October 2017 - 11:06 AM

View PostArtificialSoldier, on 20 October 2017 - 10:28 AM, said:

What format is the time saved in, and what are you searching for? Is it the same format?


I'm searching for the time_start, I didn't edit any format I'm using TIMESTAMP and it automatically gets the system time throught CURRENT_TIMESTAMP
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1829
  • View blog
  • Posts: 5,758
  • Joined: 15-January 14

Re: Searching in the GridView doesn't show results

Posted 20 October 2017 - 11:47 AM

The question is if you are searching for the time in the same format in which it is stored. If the formats are different then that's a problem. If this is a search then someone is entering or selecting a time, right? So you need to make sure that the data type is the same as what you're looking for.
Was This Post Helpful? 0
  • +
  • -

#5 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4136
  • View blog
  • Posts: 13,052
  • Joined: 08-June 10

Re: Searching in the GridView doesn't show results

Posted 22 October 2017 - 07:17 AM

Quote

I'm using TIMESTAMP

And for that the MySQL default format is y-m-d H:i:s.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1