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

3 posts, 1 answers
  1. Phil
    Phil avatar
    4 posts
    Member since:
    Dec 2011

    Posted 20 Feb 2013 Link to this post

    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. Answer
    Holger
    Holger avatar
    77 posts
    Member since:
    Nov 2012

    Posted 21 Feb 2013 Link to this post

    Hi Phil,

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

    Regards,
    Holger
  3. Kendo UI is VS 2017 Ready
  4. Phil
    Phil avatar
    4 posts
    Member since:
    Dec 2011

    Posted 21 Feb 2013 Link to this post

    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.
Back to Top