This is a migrated thread and some comments may be shown as answers.

Codeigniter and Kendo Grid

0 Answers 330 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 28 May 2012, 06:12 AM
Hello, I'm new! i have a problem creating a grid with codeigniter...i dont know how to write my kendo script. here is my code in codeigniter: 
CONTROLLER:

function read() {

    echo(json_encode($this->news_model->read());

}

function update() {
    $records = json_decode(stripslashes($this->input->get(‘models’)), true);
    $this->news_model->update($records);
}

function destroy() {
$records = json_decode(stripslashes($this->input->get(‘models’)), true);

$this->news_model->destroy($records);

}

function create() {
$records = json_decode(stripslashes($this->input->get(‘models’)), true);

$this->news_model->create($records);

}

 MODEL

function read() {
    $this->db->select(“*”);
    $query = $this->db->get(‘news’);
    if($query->num_rows() > 0) {
        $newsList = array();
        foreach($query->result() as $news) {
            $newsList[] = $news;
        }
        return($newsList);
    }
}

function update($records) {
    foreach($records as $r) {
        $this->db->where(‘id’, $r['id']);
        $this->db->update(‘news’, $r);
    }
}

function destroy($records) {

    foreach($records as $r) {

        $this->db->where(‘id’, $r['id']);
        $this->db->delete(‘news’);
    }
}

function create($records) {

    foreach($records as $r) {
        $this->db->insert(‘news’, $r);
    }
}

and now how i put this in the grid??

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Ricardo
Top achievements
Rank 1
Share this question
or