Grid client template with upload control

5 posts, 0 answers
  1. Sharon
    Sharon avatar
    4 posts
    Member since:
    Apr 2012

    Posted 21 Nov 2012 Link to this post

    I am using kendo UI web control, i tried to put the upload control inside the ajax binded grid, but it doesn't work within the client template.

    Here is the code, please let me know what is the right way to do this.

    Thanks in advance!

     @(Html.Kendo().Grid<DOC>()
            .Name("docGrid")
             .Columns(
            columns =>
            {
                columns.Bound(p => p.DocID).ClientTemplate("<input type='file' name='docs'/>");
                columns.Bound(p => p.RequiredDocName);
                columns.Bound(p => p.UploadStatus);
            })
           .Pageable()
           .Selectable(selectable => selectable.Mode(GridSelectionMode.Single))
           .DataSource(dataSource => dataSource
           .Ajax()

            .PageSize(30)
            .Batch(false)
            .ServerOperation(false)
            // .Events(events => events.Error("errorHandler"))
            .Model(model =>
            {
                model.Id(p => p.DocID);
                model.Field(p => p.RequiredDocName);
                model.Field(p => p.UploadStatus);
            })
            .Read(read => read.Action("Read", "WebApp"))))
    </div>


    <script type="text/javascript">
     
    $(document).ready(function () {
        $('[name=docs]').kendoUpload(
         {
             async:
                 {
                    saveUrl: ......
                    removeUrl: ........
                    autoUpload: true
                },
                upload: onUpload,
                success: onSuccess
         });
     });
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 26 Nov 2012 Link to this post

    Hello Sharon,

    Did you try to execute the initialization script when the dataBound event of the Grid is fired? Basically the DOM ready event is executed too early for you case, since the records are still not loaded and the tr elements are not added to the Grid.

    Kind Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Sharon
    Sharon avatar
    4 posts
    Member since:
    Apr 2012

    Posted 26 Nov 2012 Link to this post

    Hi Petur:

    Thanks for the reply. I see. Do you have any examples for the initialization script in grid databound? I will try it out.

    Sharon
  4. Sharon
    Sharon avatar
    4 posts
    Member since:
    Apr 2012

    Posted 26 Nov 2012 Link to this post

    Hi Petur:

    Did you mean instead of adding the upload control in the client template, add it in the databound? Are there any examples to add columns in the databound?
    Sharon
  5. Sharon
    Sharon avatar
    4 posts
    Member since:
    Apr 2012

    Posted 26 Nov 2012 Link to this post

    I just tried. It worked

    Thanks a lot!
Back to Top