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

Custom Editor in Grid Field showing controls based on data type of the value.

2 Answers 92 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 21 Feb 2013, 04:27 AM
Given something along the lines of below I am trying to use the custom editor function of the grid to show a different control based on the data type.  Data types are not limited to string, date, and boolean, but would also include some custom lists.  In the demo for custom editors on fields the demo leads me to believe that the editor is column based, and cannot be row based.  Is there a way to accomplish row based editors on the grid control?
<div id="me">
    <div id="kendoGrid"></div>
</div>
 
<script type="text/javascript">
    var viewModel = {
        items: []
    };
 
    viewModel.items.push({ id: 0, dataField: new Date(2012, 1, 1), dataType: 'date' });
    viewModel.items.push({ id: 1, dataField: 'any string', dataType: 'string' });
    viewModel.items.push({ id: 2, dataField: true, dataType: 'boolean' });
 
    $(document).ready(function () {
        $("#kendoGrid").kendoGrid({
            dataSource: {
                data: viewModel.items,
                batch: true,
                schema: {
                    model: {
                        id: "id",
                        fields: {
                            id: { editable: false, nullable: false },
                            dataField: {}
                        }
                    }
                }
            },
            columns: [{
                field: "dataField",
                title: "Attribute Value"
            }],
            editable:true
        });
    });
</script>

2 Answers, 1 is accepted

Sort by
0
Accepted
Holger
Top achievements
Rank 1
answered on 21 Feb 2013, 11:01 AM
Hi Phil,

I'm working on something similar. Here's a JS Bin sample: http://jsbin.com/ayacaf/4/edit

Regards,
Holger
0
Phil
Top achievements
Rank 1
answered on 21 Feb 2013, 03:24 PM
Thanks for the solution!  I was going to head down a similar route with the function, but I have limited time, so I wanted to try and get some input first whether the grid would blow up on that or not.
Tags
Grid
Asked by
Phil
Top achievements
Rank 1
Answers by
Holger
Top achievements
Rank 1
Phil
Top achievements
Rank 1
Share this question
or