Server Paging and Edit Mode= "popup" insert record problem

4 posts, 0 answers
  1. kim
    kim avatar
    3 posts
    Member since:
    Aug 2014

    Posted 15 Sep 2014 Link to this post

    I am using Kendo UI JSP. I tried Server paging and popup mode editing.

    Kengo grid operates well in delete, update. But when I add record by popup editor and saves, Idx(Primary Key)  field is not correctly updated. 

    idx PK field is generated by database trigger. It displays always "0" in grid, instead of server generated value. 

    How can I solve this problem. Idx must be updated by server generated value.


    <kendo:grid name="grid" pageable="true" height="430px" culture="ko-KR" >  
        <kendo:grid-editable mode="popup" confirmation="true"  />
        <kendo:grid-toolbar>
        <kendo:grid-toolbarItem name="create"  />
        </kendo:grid-toolbar>  
       
    <kendo:grid-columns>
    <kendo:grid-column title="번호 " field="idx" width="20px" />
            <kendo:grid-column title="제목" field="name" width="100px" />
            <kendo:grid-column title="답변1" field="reply1" width="20px"/>
            <kendo:grid-column title="답변2" field="reply2" width="20px"/>
            <kendo:grid-column title="답변3" field="reply3" width="20px"/>
            <kendo:grid-column title="답변4" field="reply4" width="20px"/>
            <kendo:grid-column title="답변5" field="reply5" width="20px"/>
            <kendo:grid-column title="답변6" field="reply6" width="20px"/>
            <kendo:grid-column title="&nbsp;" width="40px" >
           <kendo:grid-column-command>
               <kendo:grid-column-commandItem name="edit" />
               <kendo:grid-column-commandItem name="destroy" />
           </kendo:grid-column-command>
            </kendo:grid-column>                      
        </kendo:grid-columns>
          
        <kendo:dataSource pageSize="20" serverPaging="true" serverFiltering="false" serverGrouping="false" serverSorting="false" >
    <kendo:dataSource-transport>            
    <kendo:dataSource-transport-create url="${createUrl}" dataType="json" type="POST" contentType="application/json" />
                <kendo:dataSource-transport-read url="${readUrl}" dataType="json" type="POST" contentType="application/json"/>
                <kendo:dataSource-transport-update url="${updateUrl}" dataType="json" type="POST" contentType="application/json" />
                <kendo:dataSource-transport-destroy url="${destroyUrl}" dataType="json" type="POST" contentType="application/json" />
                    
              <kendo:dataSource-transport-parameterMap>
                  function(options){return JSON.stringify(options);}
                </kendo:dataSource-transport-parameterMap>              
    </kendo:dataSource-transport>
              
    <kendo:dataSource-schema data="data" total="total" groups="data"  > 
           <kendo:dataSource-schema-model id="idx">
               <kendo:dataSource-schema-model-fields>
                   <kendo:dataSource-schema-model-field name="idx" type="number" editable="false" />                   
                   <kendo:dataSource-schema-model-field name="name" type="string" />
                   <kendo:dataSource-schema-model-field name="question1" type="string" />
                   <kendo:dataSource-schema-model-field name="question2" type="string" />
                   <kendo:dataSource-schema-model-field name="question3" type="string" />
                   <kendo:dataSource-schema-model-field name="question4" type="string" />
                   <kendo:dataSource-schema-model-field name="question5" type="string" />
                   <kendo:dataSource-schema-model-field name="question6" type="string" />
                   <kendo:dataSource-schema-model-field name="reply1" type="number" editable="false" />
                   <kendo:dataSource-schema-model-field name="reply2" type="number" editable="false" />
                   <kendo:dataSource-schema-model-field name="reply3" type="number" editable="false" />
                   <kendo:dataSource-schema-model-field name="reply4" type="number" editable="false" />
                   <kendo:dataSource-schema-model-field name="reply5" type="number" editable="false" />
                   <kendo:dataSource-schema-model-field name="reply6" type="number" editable="false" />
               </kendo:dataSource-schema-model-fields>
           </kendo:dataSource-schema-model>
    </kendo:dataSource-schema>
    </kendo:dataSource>
    </kendo:grid>





  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 16 Sep 2014 Link to this post

    Hello Kim,

    In order to update the ID on the client-side, the server should send it back as a response to the Create request. Here is example from our offline demos: 
    @RequestMapping(value = "/editing-popup/create", method = RequestMethod.POST)
    public @ResponseBody Product create(@RequestBody Map<String, Object> model) {
        Product target = new Product();
         
        target.setProductName((String)model.get("productName"));
        target.setUnitPrice(Double.parseDouble(model.get("unitPrice").toString()));
        target.setUnitsInStock((int)model.get("unitsInStock"));
        target.setDiscontinued((boolean)model.get("discontinued"));       
         
        product.saveOrUpdate(target);
         
        return target;
    }


    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. UI for ASP.NET AJAX banner
  4. kim
    kim avatar
    3 posts
    Member since:
    Aug 2014

    Posted 16 Sep 2014 in reply to Alexander Popov Link to this post

    I already have tested above code as you recommended.  In not server paging mode, Auto incremented ID field updates well.

    But, in server paging mode, ID field is not updated. Normal field updates well, only Id field which generated by server is not updated in server paging mode.
  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 18 Sep 2014 Link to this post

    Hello again Kim,

    Whether server paging or client paging is used should not have any difference, because the ID is populated when the controller responds to the Create request. Here is a screencast showing the process.
    I am not exactly sure why the ID is not updated in your case, so I would ask you to provide more code snippets, or ideally - a runnable sample project where the issue is reproduced.

    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top
UI for ASP.NET AJAX banner