Suggestions Powerful Grid

Hi everyone,

I need a grid to rule them all…

We’re building this huge system… We’ll replace all the Ms Access based system. All the people are used to in-cell editing grids and I don’t want them to complain about multiple clicks editing tables.

So, in your experience, what grid component or solution or suggestion do you have or applied to this issue?

PD. I’ve searched across the web and didn’t found anything that convinced me.

Thanks in advanced and sorry for my english…

Sencha extjs.

Actually Im studying it right now. It seems complex =(

Thank You!

PS. As for me, I came up with my own lightweight solution based on knockoutJS.

Do you have any tutorial?

Thanks

http://knockoutjs.com/documentation/introduction.html

Pay attention to "Further techniques" and "The mapping plugin".

KO v2 is fcking awesome, btw.

Looks quite interesting!!

Thanks!

Hi,

I am designing an application for a restaurant and need to create a view for an order with an inbuilt list for the items ordered. I am looking for a way to input the items data in a table. I have tried the ztabularinputmanager with some limited success: I have been able to input new data when I input a new record but am having some problems to update data relative to an existing record. I had a look at the tutorial you suggested and the lists and collection are exactly what I need to do. I see you have worked with KO and would like to have some hint (if possible a sample code) about how to integrate it with Yii. Can you please help me? Thanks

No idea what ztabularinputmanager is, sorry.

Well, KO part is simple, you just pass json array to viewmodel, then you can do whatever you want.

View:


<script type="text/javascript">

    var dg_order = new orey.DataGrid({ // this is my view model

        collection: <?= CJSON::encode($collection) ?>,

    });


    ko.applyBindings(dg_order, document.getElementById('gridPanel'));

</script>

And now the funny part (not so funny actually).

Controller:


$list = MyModel::model()->findAll($criteria);


// I hate loops

$jsonlist = array();

foreach ($list as $item) {

	$jsonlist[] = $item->json; // my own method for converting to JSON

}

Currently I have no idea how to make it better under ActiveRecord (avoiding extra loops, converting AR models to JSON using only required fields and relations and so on) :(

Saving can be done in two ways:

  1. by submitting editor form

  2. by sending ajax post with json

I prefer the latter.


$.ajax(url, {

    type: 'POST',

    data: {

        YII_CSRF_TOKEN: self.config.csrfToken,

        jsondata: ko.mapping.toJSON(self.selectedItem)

    },

    ...

}

Thanks ORey for your prompt reply.

After reading your code once, I do not quite understand it. The thing is that I am quite new at PHP and newer at Yii. In fact, it is my first project in PHP with Yii. I will try to understand it. My first issue is to retrieve data from my database table into KO, display it in a table in KO where I can add or delete, then save it back to my database table. It looks like a challenge for me right now :-[

My advice for you: start with some tutorials, and then try to write your own project not using neither extensions nor code generation tools.

And then you can try to add some spice using JS, ajax and so on.

Thanks. I have gone quite a long way with the project but am stuck on this editable grid.

For simple editable grids you can use jquery plugins, for example jquery.jeditable.

Thanks again. You are very helpful :)

It’s very helpful for me too. thanks

Hello Orey,

I just checked out ‘KO’. As you said, it seems pretty awesome++. Now the View Model is similar to Model in yii mcv?

What do you advice in order to know this KO very well?

Thx

Complete the tutorial and then try to use it on your projects.

Also looking at github code may help.