Telerik Forums
UI for JSP Forum
3 answers
91 views
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>





Alexander Popov
Telerik team
 answered on 18 Sep 2014
1 answer
121 views
How can I set popup editor's template?

Following code does't work.
 

<kendo:grid name="grid">
    <kendo:grid-editable confirmation="true"  mode="popup" template="editTemplate" />

...
...    

<script type="text/x-kendo-template" id="editTemplate">   
    <input id="productId" type="text" >
    <input id="productName"  type="text" >
    <input id="unitPrice"  type="text" >
    <input id="unitsInStock"  type="text" >
</script>
Alexander Popov
Telerik team
 answered on 18 Sep 2014
1 answer
69 views
I am new to Kendo and I am testing out the grid functionality using the JSP tag library with the Grid control.

In my Java code I am building up a List<Employees> and setting it as an attibute in the request. The Employee class is simple, being 

    private int EmployeeID;
    private int ManagerID;
    private String LastName;
    private String FirstName;

with accompanying getters and setters.

I am sending it to the JSP page using
     request.setAttribute( "theData", employees);

I have successfully displayed the grid using the following tags in my JSP page.

                <kendo:grid name="grid1" id="grid1"
                    sortable="true"
                    groupable="true">
                    <kendo:grid-pageable buttonCount="5" pageSize="5" info="true">
                    </kendo:grid-pageable>
                     
                    <kendo:dataSource data="${theData}">
                    </kendo:dataSource>
                    <kendo:grid-columns>
                        <kendo:grid-column field="firstName" title="First Name"   width="80px" />
                        <kendo:grid-column field="lastName" title="Last Name"  width="80px"/>
<%--                         <kendo:grid-column field="employeeID" title="Employee ID"  /> --%>
<%--                         <kendo:grid-column field="managerID" title="Manager ID"  /> --%>
                    </kendo:grid-columns>
                 </kendo:grid>

I have also sucesfully displayed the grid if I remove the entire kendo:grid-columns tag. Therefore I know that my data path is wired up correctly.

If I uncomment out either of the grid-columns (employeeID or managerID) the page throws a NullException error at

    at com.kendoui.taglib.BaseTag.setProperty(BaseTag.java:67)
    at com.kendoui.taglib.grid.ColumnTag.setField(ColumnTag.java:137)
     ...

Any combination of two data columns displays as expected but adding a third or fourth one cases the exception. Is this something I am doing wrong? Is this a known issue with the JSP tag libraries?

Thanks for any help you can provide.

Steven

Atanas Korchev
Telerik team
 answered on 26 Aug 2014
3 answers
99 views
Hi
This is Ganesh and I'm completely new to this framework.

I've a requirement to show all the Employee details from database.  I'm using MySQL Database.

And I must show those results in a tabular format.

Whatever details I've shown in the grid or table they details must be editable. i.e., you can update or delete those records.

Kindly help me in this issue. 
I'm using Eclipse 4.3 version. 

Thank you.

Regards,
Ganesh Kumar K
ganesh.asp.net@hotmail.com
Vladimir Iliev
Telerik team
 answered on 01 Jul 2014
3 answers
303 views
Hi,

I'm returned a list of java objects in my controller and using kendo taglibs to successfully outputting the data, but I'm having some issues displaying the date correctly for one my attributes. The attribute I'm returning is a Date object.

It's been outputted as a numeric i.e. 1342438812000. I thought I may need to format and or parse the date.

I've tried to update the grid column to

 <kendo:grid-column title="DatePublished" field="datePublished" width="110" format="{0:MM/dd/yyyy}" template="kendo.toString(datePublished, 'MM/dd/yyyy')"/>

or
<kendo:grid-column title="DatePublished" field="datePublished" width="110" format="{0:MM/dd/yyyy}" template='#= kendo.toString(datePublished, "yyyy/MM/dd") #'/>

though I'm having little luck outputting the date format correctly..

I could change it to a string in java, though I want to add some filtering to the date when I have it outputted.

Anyone have any ideas?

Thanks
Petur Subev
Telerik team
 answered on 24 Apr 2014
3 answers
2.1K+ views
We are struggling to bind dynamic columns and there values as a rows to Kendo UI grid, reason is that new columns can be added to table at a later stage and that also needs to be displayed on the grid.
We also need server side paging, sorting and filtering and need to deal with large amount of data.

Its a Spring Rest call from angular JS:
this.executeQuery = function () {
var service = $resource('/searchandreplay/rest/executeQuery', null, { 'save': { method: 'POST', isArray: true}});
service.save(this.registry.activeQuery, function (response) {
console.log('response: ' + response);
});
};
Here response is an json, attached response.json

Want to populate/make visible Kendo Grid on click event of button.  












Vladimir Iliev
Telerik team
 answered on 11 Apr 2014
1 answer
85 views
I have a grid defined in JSP and I need to localize column titles. Is it possible to get values from message resource bundle into column title?
<kendo:grid name="gridId" >
    <kendo:grid-columns>
        <kendo:grid-column title="Column Title 1" field="field1"  />
    </kendo:grid-columns>
</kendo:grid>
I.e. - how to localize "Column Title 1" ?
Atanas Korchev
Telerik team
 answered on 24 Jan 2014
8 answers
210 views
############### remote-data.jsp ###########################

<%@taglib prefix="kendo" uri="http://www.kendoui.com/jsp/tags"%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<c:url value="/web/grid/remote-data/read" var="transportReadUrl" />

<kendo:grid name="grid" pageable="true" height="430px" sortable="true" filterable="true" groupable="true">
<kendo:grid-scrollable/>
<kendo:grid-columns>
<kendo:grid-column title="Order ID" field="orderId" width="100px" filterable="false" />
<kendo:grid-column title="Freight" field="freight" width="100px" />
<kendo:grid-column title="Order Date" field="orderDate" format="{0:MM/dd/yyyy}" width="140px"/>
<kendo:grid-column title="Ship Name" field="shipName" />
<kendo:grid-column title="Ship City" field="shipCity" width="150px" />
</kendo:grid-columns>
<kendo:dataSource pageSize="20" serverPaging="true" serverSorting="true" serverFiltering="true" serverGrouping="true">
<kendo:dataSource-transport>
<kendo:dataSource-transport-read url="${transportReadUrl}" 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>
<kendo:dataSource-schema-model-fields>
<kendo:dataSource-schema-model-field name="orderId" type="number" />
<kendo:dataSource-schema-model-field name="freight" type="number" />
<kendo:dataSource-schema-model-field name="orderDate" type="date" />
<kendo:dataSource-schema-model-field name="shipName" type="string" />
<kendo:dataSource-schema-model-field name="shipCity" type="string" />
</kendo:dataSource-schema-model-fields>
</kendo:dataSource-schema-model>
</kendo:dataSource-schema>
</kendo:dataSource>
</kendo:grid>

<kendo:dataSource-schema-model-field Name="freight" type="number" /> on this part of the text, but how do you centered? In other words, freight field only "text-align: center;" I want to give the effect.
Jong Woo
Top achievements
Rank 1
 answered on 17 Jan 2014
2 answers
122 views
Hi kendo ui team,
On expand i make post request which returns list from a hashmap depending on requested id. Each rendered list is a nested row inside grid with unique id.
Issue is while expending each row i get only 1st nested row updated with results basically row id reference is missing and grid widget doesn't know which nested row to update. Any suggestions and recommendations appreciated.

here is some code:
JSP
<%               
    HashMap<String, Object> data = new HashMap<String, Object>();
    data.put("itemId", "#=itemId#");
%>
 
<kendo:grid name="item" pageable="true" detailTemplate="template">
    <kendo:dataSource>
        <kendo:dataSource-transport>
            <kendo:dataSource-transport-read url="http://localhost:8080/GrubbyUI/api/items" />
        </kendo:dataSource-transport>
        <kendo:dataSource-schema data="data" total="total" />
    </kendo:dataSource>
    <kendo:grid-columns>
        <kendo:grid-column title="id" field="itemId"></kendo:grid-column>
    </kendo:grid-columns>
</kendo:grid>
 
<kendo:grid-detailTemplate id="template">
    <kendo:grid name="innerData">       
        <kendo:dataSource>
            <kendo:dataSource-transport>
                <kendo:dataSource-transport-read url="http://localhost:8080/GrubbyUI/api/items"
                    data="<%=data %>" type="POST" contentType="application/json "/>
                <kendo:dataSource-transport-parameterMap>       
                    <script>
                         function parameterMap(options) {
                            return JSON.stringify(options);
                         }
                    </script>
                 </kendo:dataSource-transport-parameterMap>                   
            </kendo:dataSource-transport>
        </kendo:dataSource>
        <kendo:grid-columns>
            <kendo:grid-column title="id" field="itemId"></kendo:grid-
           <kendo:grid-column title="Date Added" field="dateAdded"></kendo:grid-column>
        </kendo:grid-columns>           
    </kendo:grid>
</kendo:grid-detailTemplate>
Java servlet:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     
    try {
        // objects for keeping data structures
        DataModel result = new DataModel();
        DataSourceResult data = new DataSourceResult();
        Gson gson = new Gson();
 
        data.setData(result.listOfItems());
        data.setTotal(result.getTotal());
         
        response.setContentType("application/json");
        response.getWriter().write(gson.toJson(data));
     
    } catch (Exception e) {
        response.sendError(500);
        e.printStackTrace();
    }
}
 
/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
 
    Gson gson = new Gson();
           // some random data for testing purposes
    HashMap<String, List<Item>> data = new HashMap<String, List<Item>>(); // response data struct
    List<Item> l1 = new ArrayList<Item>();
    List<Item> l2 = new ArrayList<Item>();
    BufferedReader reader = request.getReader();
     
    String line = reader.readLine();
    Map<String, String> map = gson.fromJson(line, Map.class);
    String selectedId = map.get("itemId");
    System.out.println(selectedId);
 
    // init data var
    Item item1 = new Item("lib", "#1", false, "date");
    Item item2 = new Item("lib 2", "#2", true, "date");
    l1.add(item1);
    l1.add(item2);
    data.put("1", l1);
     
    item1 = new Item("lib 3", "#3", true, "date");
    item2 = new Item("lib 4", "#4", false, "date");
    l2.add(item1);
    l2.add(item2);
    data.put("2", l2);
     
    response.setContentType("application/json");
    response.getWriter().write(gson.toJson(data.get(selectedId)));
}


Alex
Top achievements
Rank 1
 answered on 15 Jan 2014
6 answers
177 views
(core)jsp without using spring only being implemented Binding to remote data.

test.jsp and test_data.jsp search, sorting, paging, try to implement.

############# /test.jsp ########################
<kendo:grid name='grid' pageable='true' sortable='true' filterable='true' columnMenu='true'>
<kendo:grid-columns>
    <kendo:grid-column title='Order ID' field='orderId' />
  <kendo:grid-column title='Ship Country' field='shipCountry' />
  <kendo:grid-column title='Ship Name' field='shipName' />  
  <kendo:grid-column title='Ship Address' field='shipAddress' />        
</kendo:grid-columns>
<kendo:dataSource pageSize='10' serverPaging='true' serverSorting='true' serverFiltering='true'>
    <kendo:dataSource-transport>             
 <kendo:dataSource-transport-read url='/test_data.jsp' type='POST'  contentType='application/json'/>
 <kendo:dataSource-transport-parameterMap>
  <script>
   function parameterMap(options) {     
    return JSON.stringify(options);                   
   }
  </script>
 </kendo:dataSource-transport-parameterMap>               
    </kendo:dataSource-transport>
    <kendo:dataSource-schema data='data' total='total'>
     <kendo:dataSource-schema-model>
  <kendo:dataSource-schema-model-fields>
      <kendo:dataSource-schema-model-field name='orderId' type='number' />
      <kendo:dataSource-schema-model-field name='shipCountry' type='string' />
      <kendo:dataSource-schema-model-field name='shipName' type='string' />
      <kendo:dataSource-schema-model-field name='shipAddress' type='string' />
  </kendo:dataSource-schema-model-fields>
     </kendo:dataSource-schema-model>
 </kendo:dataSource-schema>
</kendo:dataSource>
<kendo:grid-pageable />
</kendo:grid>

############# /test_data.jsp ########################
<%@ page contentType='text/html; charset=utf-8' %>
<%
 response.setContentType('application/json');
%>
{'orderId':'26','shipCountry':'acanet','shipName':'wdkang','shipAddress':'wdkang'},{'orderId':'27','shipCountry':'acanet1','shipName':'wdkang1','shipAddress':'wdkang1'}

test_data.jsp written as above, but of course "No items to display" coming out.

1. How should receive the parameters test_data.jsp?

2. How would you describe the json data test_data.jsp should I do?


In other words,

header('Content-Type: application/json');$request = json_decode(file_get_contents('php://input'));$result = new DataSourceResult('sqlite:../../sample.db');echo json_encode($result->read('Orders', array('ShipName', 'Freight' => array('type' => 'number') , 'OrderDate', 'OrderID', 'ShipCity'), $request));

Pure jsp, php code above if you want to implement, what should I do?
Jong Woo
Top achievements
Rank 1
 answered on 03 Jan 2014
Top users last month
Mark
Top achievements
Rank 1
Yurii
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Hon
Top achievements
Rank 1
Iron
Deltaohm
Top achievements
Rank 3
Bronze
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?