Friday, 27 November 2015

Jquery Data table for delete on click on button

<%-- <%@page import="com.bc.basil.model.CustomOrgConfiguration"%>
<%@page import="com.bc.basil.service.CustomOrgConfigurationLocalServiceUtil"%> --%>
<%-- <%@page import="com.liferay.portal.kernel.util.ParamUtil"%> --%>
<%@page import="com.bc.basil.service.CustomOrgConfigurationLocalServiceUtil"%>
<%@page import="com.bc.basil.model.CustomOrgConfiguration"%>
<%@page import="javax.portlet.PortletURL"%>

<%@ include file="init.jsp" %>
<portlet:defineObjects />
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css"/>

<portlet:renderURL var="regionUrl">
<portlet:param name="action" value="add_region"/>
</portlet:renderURL>
<a href="<%=regionUrl%>">Add</a>

<%
Organization org=null;
List<Organization> organisationsList=OrganizationLocalServiceUtil.getOrganizations(-1, -1);

PortletURL deleteRegionURL = renderResponse.createActionURL();
deleteRegionURL.setParameter("action", "deleteRegion");



PortletURL saveURL=renderResponse.createActionURL();
saveURL.setParameter("action", "saveRegion");


List<CustomOrgConfiguration> customOrgConfigurationList = CustomOrgConfigurationLocalServiceUtil.getCustomOrgConfigurations(-1, -1);
%>


</br>



<div>
<table id="regionTable"  border="1" cellspacing="0" width="100%">
<thead>
   <tr>
        <th>OrganizationId</th>
       <th>Parent OrganizationId</th>
       <th>Type</th>
        <th>Code</th>
       <th>Action</th>
   </tr>
</thead>
<tbody>

<c:if test="<%=customOrgConfigurationList!=null %>" >

<% for (CustomOrgConfiguration ConfigurationScreen :customOrgConfigurationList) {

deleteRegionURL.setParameter("customId",  String.valueOf(ConfigurationScreen.getCustomId()));
%>


<tr>
<td><%=  OrganizationLocalServiceUtil.getOrganization(ConfigurationScreen.getOrganizationId()).getName() %></td>
<td><%= OrganizationLocalServiceUtil.getOrganization(ConfigurationScreen.getParentOrgId()).getName()%></td>
<td><%= ConfigurationScreen.getType()%></td>
<td><%= ConfigurationScreen.getCode()%></td>
   <td><button class="edit" >Edit File</button>
   <a href="<%=deleteRegionURL.toString()%>"> <button class="remove" >Delete File</button></a></td>

</tr>


<% } %>
</c:if>

</tbody>
</table>
</div>


<script type="text/javascript">
$(document).ready(function() {
    $('#regionTable').DataTable();
} );
</script>

No comments:

Post a Comment