Getting the search container checkbox values in the Liferay


In liferay if we see the search container they have the chexkboxes which default liferay creates. So how do we reterive the those checkbox values in the javascript?

Here is the code to retrieve the chexkbox values in javascript.


Liferay.provide(
window,
'<portlet:namespace />updateStatus',  // Name of the javascript function.
function(cmd) {
      var updateStatus = true;

       var updateUserIds = Liferay.Util.listCheckedExcept(document.<portlet:namespace />fm, "<portlet:namespace />allRowIds");  // Getting the checked checkboxes values , Here "fm" is the form name.

      if (!updateUserIds) {
           updateStatus = false;
      }

//Here based on the user click we are displaying the message.
else if (cmd == "deActive") {
     if (!confirm('<%= UnicodeLanguageUtil.get(pageContext, "are-you-sure-you-want-to-deactivate-the-  selected-users") %>')) {
       updateStatus = false;
       }
}
else if (cmd == "active") {
      if (!confirm('<%= UnicodeLanguageUtil.get(pageContext, "are-you-sure-you-want-to-active-the-selected-users") %>')) {
       updateStatus = false;
     }
}

// Here we are submitting the form. 

if (updateStatus) {
document.<portlet:namespace />fm.method = "post";
document.<portlet:namespace />fm.<portlet:namespace />cmd.value = cmd;
document.<portlet:namespace />fm.<portlet:namespace />updateUserIds.value = updateUserIds;
submitForm(document.<portlet:namespace />fm, "<portlet:actionURL name="updateStatus"></portlet:actionURL>");
}
},
['liferay-util-list-fields']
);

Comments

Popular posts from this blog

How to know which liferay version we are using

Viewing the SQL Query in liferay : debugging the SQL Query in Hibernate

Opening portlet in popup