Liferay Portal 6.2 - checkbox into search container - search

I created a search container table that contains a column checkbox type, i.e.
<liferay-ui:search-container-column-text
name="territoriale"
orderable="<%= true %>"
>
<input type="checkbox" id="territoriale" checked="<%= cmt.getTerritoriale() == 1 %>" />
</liferay-ui:search-container-column-text>
This table is declared inside a jsp included using liferay-util:include, but can also be refreshed in the next steps by click on search button.
What happen is that when the table appears for the first time, I see that column just with text (value is "1"), when I click search button that runs the ajax call, the resource action return the correct checkbox in column.
Any ideas?
Below some screen shot
Thanks
Column after page load
Column after click on search button

This works fine on 6.2 CE ga5:
<liferay-ui:search-container-column-text
name="checkbox"
orderable="<%= true %>"
>
<% String checked = (Math.random() < 0.5) ? "checked" : ""; %>
<input type="checkbox" <%= checked %>/>
</liferay-ui:search-container-column-text>
So the root cause of your issue should be somewhere else. You may output cmt.getTerritoriale() into html to check its content.
I think, that checked="<%= cmt.getTerritoriale() == 1 %>" is not correct,
you may use checked or nothing.
See here about using checked attribute.
You can also use rowchecker as was mentioned in the comments of Pankajkumar Kathiriya.

Related

Angular changing a select value to null based on other select change

i am trying to add a popup form using an ng-template which have multiple selects .on ngOnInit() i add all the values as null
some of these selects are shown based on the previous select value using ngif
the problem is that when i change the value the second select go away but its value still the same this is my code :
<div *ngIf="cosForm.value.customer=='617e7d83c68272eba7c36c13'">
<div class="form-group text-right">
<label class="col-form-label" for="service">customer</label>
<select ng-model="selectedItem" class="form-control" placeholder="customer" autocomplete="customer"
formControlName="customer" required
[ngClass]="{ 'is-invalid': submitted && f.customer.errors, 'is-valid': f.customer.touched && !f.customer.errors }">
<option *ngFor="let customer of myCustomers" value="{{customer._id}}">{{customer.name}}</option>
</select>
<div *ngIf="submitted && f['customer'].errors" class="invalid-feedback">
<div *ngIf="f['customer'].errors.required">customer is required</div>
</div>
</div>
i want when i change the first select value the second ng select value set to null
i tried to use
<select onChange="cosForm.value.customer=null"> </select>
on the first select but i didnt get any result
i wanted to use :<div *ngIf="cosForm.value.customer=='!617e7d83c68272eba7c36c13'">
but i couldn't figure out how to affect the value
BTW: even if i change the first select, without changing the second ,i think the second select value is automatically changed because my submit button change to invalid and it became valid only when i fill the second select
If you are trying to invalidate another select based on one select then you can listen to changes in the first select tag with this
form.controls.customer.valueChanges.subscribe(()=>{
// Set the value of the second select to null here
form.controls.secondSelect.reset()
})

How to click on Web check box using Excel VBA?

How do I check the table checkbox?
I tried clicking.
ie.Document.getElementsByClassName("x-grid3-hd-checker").Checked = True
<div class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on" unselectable="on" style="">
<a class="x-grid3-hd-btn" href="#"></a>
<div class="x-grid3-hd-checker"> </div>
<img class="x-grid3-sort-icon" src="/javascript/extjs/resources/images/default/s.gif">
</div>
I can't see a checkbox in the HTML code. But you use getElementsByClassName() in a wrong way for your case. getElementsByClassName() generates a node collection. If you need a specific node, you must get it by it's index in the node collection. First element has index 0.
Please note that the div tag with the CSS class class="x-grid3-hd-inner x-grid3-hd-checker x-grid3-hd-checker-on " is also included in the Node Collection, because a part of the class identifier is identical to "x-grid3-hd-checker ". [Edit: I'm not realy sure if the part must maybe stand at the begin of the identifier]
If you want to check this:
<div class="x-grid3-hd-checker"> </div>
Your code needs the second index of the node collection:
ie.Document.getElementsByClassName("x-grid3-hd-checker")(1).Checked = True
But if there are more tags with the class name "x-grid3-hd-checker" the above line don't work. I can't say anymore until you don't post more HTML and VBA code. The best would be a link to the site.

How to click Save button on a web form using VBA

I am working on automating a task. I want to click a Save button on a web form using VBA, but it's not working:
<input name="save" title="Save" class="btn" type="submit" value=" Save ">
<input name="save" tabindex="79" title="Save" class="btn" type="submit" value=" Save ">
I've tried ie.Document.all("save").Click, but it doesn't seem to work. What method do I need to click the button?
You can try going through all your "btn" class collection, and click the one with your save value:
Dim btnClassColl As Object, btn As Object
Set btnClassColl = ie.document.getElementsByClassName("btn")
For Each btn In btnClassColl
If btn.Value Like "*save*" Then
btn.Click
Exit For
End If
Next
Also: make sure that your web page has FULLY loaded before trying to automate anything.
Edit
In response to the comment:
This code is neither giving error nor its clicking on btn. Can this be because there are two buttons on web page with same name and function?
An alternative solution would be that if you know the index number of the collection item, you can simply use that index number and not loop at all. In this case, your index # is 1 (remember: Base 0).
Try this alternative:
Dim btn As Object
ie.document.getElementsByName("save")(1) '1 actually means #2 in index

Issue with checked checkbox in Liferay/Alloy UI

I have a form which has the checkbox. I am saving the check box value as true/false based on selecting of the check box. If I open the form in a edit mode, I am able to get the value from DB as true or false. Now I get the value as true I need to show the checked checkbox in my form OR If the value is false then I need to show the unchecked checkbox. please give me some suggestions.
<%= user.isadmin() %> // here I am getting either true or false
Based on above value I need to check or uncheck the check box,
<aui:input type="checkbox" name="isadmin" label="Is Admin"></aui:input>
If I use,
<aui:input type="checkbox" name="isadmin" label="Is Admin" checked="<%= user.isadmin()>"></aui:input>
Though user.isadmin() value is true, I am getting an error.
Use following way for checking checkbox based on the value of user.isadmin()
<% String checked = user.isadmin() ? "checked" : "" %>
<aui:input type="checkbox" name="isadmin" label="Is Admin" <%=checked %>></aui:input>

How to click a edit button when its defined under repeated similar ids

I have a page where many edit buttons are there. And each button have same id i.e enable_edit_content . How to click a specific button .
This is the code where i have to click
<div class="sub-controls" id="motion_eligibility_entry-subcontrols">
<button class="btnedit" **id="enable_edit_content"** name="button" type="button"></button>
<input class="btnsave submit_form" id="save_motions_eligibility_entry" name="commit"
type="submit" value="" disabled="disabled">
<button class="btnkill" id="cancel_content" name="button" type="button"
disabled="disabled"></button>
</div>
Any help will be highly appreciated.
I have tried but could not get my results :-
1) page.all(:css, '#enable_edit_content').each_with_index do |el, i|
i += 1
if i == 3
el.click
end
end
2)find(:xpath, "//div[#id='motion_eligibility_entry-subcontrols']/button[1]").click
you can also scope down your css selector with a within block.
within('.sub-controls) do
page.find('#enable_edit_content).click
end
Because of this very issue, I'd highly recommend shying away from xpath and use css selectors instead!
Hope this helps.

Resources