treegrid sum column

65 views
Skip to first unread message

Enrique Moreira

unread,
Oct 16, 2012, 11:43:31 PM10/16/12
to hobo...@googlegroups.com
Hello
Hobousers 


I need a grid treegrid? to render a multicolum with n levels deep, like Master - Detail, one o many columns have a numeric value or sum ajax? , a grid from jquery? extjs? any guide to hobo 


thanks

Enrique

Bryan Larsen

unread,
Oct 17, 2012, 7:32:30 AM10/17/12
to hobo...@googlegroups.com
Will this work for you?

http://cookbook.hobocentral.net/api_plugins/hobo_tree_table

A tree table isn't generally paginated, so you can create a sum column
by defining a method on your model called sum:

def sum
children.sum(amount)
end

where children is the name of your has_many, and amount is the name of
the column that holds a numerical value to sum.

Bryan
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To post to this group, send email to hobo...@googlegroups.com.
> To unsubscribe from this group, send email to
> hobousers+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/hobousers?hl=en.

Bob Sleys

unread,
Oct 17, 2012, 10:58:58 AM10/17/12
to hobo...@googlegroups.com
You can also look into used the Kendoui grid. It has what you want but will take a bit of work to get to work with Hobo.  (there is another thread https://groups.google.com/forum/#!topic/hobousers/7HsskOYIPBc%5B1-25%5D on it).  One option I found was to place the data fro the grid into a javascript object with something like the below, just watch your datatypes, ie place strings in quotes, numbers without them and convert dates to date objects.

<script language='JavaScript' type='text/javascript'>
            var data = []
            <repeat with= "&@tickets">
            data.push({
            equipment: "#{this.equipment}",
            ticket: "#{this.problem}",
            by: "#{this.submitted_by}",
            updated: new Date("#{this.updated_at}"),
            status: "#{this.status}",
            tech: "#{this.technician}"
        });
            </repeat>
</script>

Then setup the grid.  Once the grid and identify the data prroperly all the kendui grid features seem to work fine.  Note my example isn't doing a tree view with totals etc but the grid has those fetures. (http://demos.kendoui.com/web/grid/aggregates.html)

<custom-javascript:>
                $(document).ready(function() {
                    $("#data-table").kendoGrid({
                    dataSource: data,
                    schema: {
                                model: {
                                    fields: {
                                        equipment: { type: "string" },
                                        ticket: { type: "string" },
                                        by: { type: "string" },
                                        updated: { type: "date" },
                                        status: { type: "string" },
                                        tech: { type: "string" }
                                    }
                                }
                        },
                        height: 500,
                        groupable: false,
                        sortable: {
                            mode: "multiple",
                            allowUnsort: true
                        },
                        scrollable: true,
                        resizable: true,
                        columns: [
                            {
                                field: "equipment",
                                title: "Gym - Equipment",
                                width: 200
                            },
                            {
                                field: "ticket",
                                title: "Issue",
                                width: 300
                            },
                            {
                                field: "by",
                                title: "Submitted By",
                                width: 100
                            },
                            {
                                field: "updated",
                                title: "Last Update",
                                format: "{0:MMM/dd/yyyy}",
                                width: 100
                            },
                            {
                                field: "status",
                                title: "Status",
                                width: 50
                            },
                            {
                                field: "tech",
                                title: "Assigned To",
                                width: 100

                            }
                        ]
                    });
                });
</custom-javascript:>

Bob
Reply all
Reply to author
Forward
0 new messages