Apex5.0, how to make a checkbox readonly - oracle-apex

i have below select statement, I want to amend it to make the checkbox READ-ONLY.
how is it possible to do that pls??
SELECT emp_id,
emp_name,
emp_title,
APEX_ITEM.CHECKBOX(p_idx => 10, p_value => id , p_attributes => DECODE(status,'Y','checked="checked"', NULL)) status,
FROM emp_tbl WHERE emp_id = :P1_emp_id;

Depending on what exact behaviour you want, you could try either
1) adding to the attribute (p_attributes): disabled
or
2) adding to the attribute (p_attributes): onclick="return false;"
Hope this is of some help.

Include following change
p_attributes => DECODE(status,'Y','checked="checked" onclick="return false;"', 'onclick="return false;"')
Hope this will help you !

You can use 'readonly=readonly' property in check box.
Kindly check the case from Google as this is case sensitive.
Regards,
Nikita

Related

Emberjs 1.8 handlebars "view select" set default value/prompt text with variable

I want to set a default value or prompt a text to my select dropdown, I have managed to get the correct content into the select, but I want to be able to have a default value that differs from the content, for example " select country " and then list the countries.
This is how the select looks like so far, and the testing variable looks like this: testFillSelect: "Select Country..",
<div class="form-group">
<label>Countries:</label>
{{view "select2"
prompt="Select country.."
content=countries
optionValuePath="content.id"
optionLabelPath="content.name"
selectionBinding=testFillSelect
selection=countries.id
class="form-control"}}
</div>
The problem is, the selectionBinding doesn't seem to work as it does nothing, and niether does the prompt unless it's a blankspace in a string. I have tried select and select2, didn't make any difference either.
Does anyone have any idea of how to do this properly?
I thought I'd just leave an answer here in case anyone stumbles upon the same problem in the future, with this ember version.
Inspired by Lux comment, I passed an object as the first object in the content array instead, I did this using unshiftObjects which is supported by this ancient ember version believe it or not. (The first object is what is shown in the select if there's data in it & there's no prompt in the select view)
Code example of what I did:
this.set('countries', countries.unshiftObjects({id:-1, name:"Select country.."}));
And a validation that checks if a post is made with id -1 and in that case treat it as if nothing was selected.
Note that there are probably better ways to go about this & this is a workaround, but it's what worked for me :)

Primeng KeyFilter not working well

i am using KeyFilter Module of primeng here is my code :
<input type="text" pInputText [(ngModel)]="price.TintCost" [pKeyFilter]="patternDecimal" name="tintCost" required="true" />
here is my typescrip code :
patternDecimal: RegExp = /^[0-9]+(\.[0-9]{1,2})?$/;
and here is version of primeng :|
"primeng": "^5.2.0-rc.1",
i tested in regex then i can type dot(.) but when i apply to KeyFilter, it doesn't allow the dot(.). Someone help me, please
I solved this problem by adding a mask as default
KeyFilter.DEFAULT_MASKS['currencyRegex'] = /^-?(?:0|[1-9]\d{0,2}(?:,?\d{3})*)(?:\.\d+)?$/;
I solved this problem by change the pValidateOnly property to true.
The problem is that the KeyFilter check any press on keyboard and if the complete value is no the correct, then dont permit write, just if you copy and paste the value.
In the documentation say
Instead of blocking a single keypress, the alternative validation mode
which is enabled with pValidateOnly property validates the whole input
with a built-in Angular validator.
https://www.primefaces.org/primeng-6.1.6/#/keyfilter
Example that work for me.
Component.ts
public twoDecimal: RegExp = /^\s*-?(\d+(\.\d{1,2})?|\.\d{1,2})\s*$/
Component.html
<input name="decimalField"
#decimalField="ngModel"
[pKeyFilter]="twoDecimal"
[pValidateOnly]="true"
[(ngModel)]="item.decimalField"
type="text" pInputText>
<div *ngIf="!decimalField.valid" class="alert alert-danger">
<p>Incorrect format.</p>
</div>
The answer of #Norberto Quesada is correct.
Without pValidateOnly the regex will validate on every key stroke.
Let's say you want to enter the value "47.11":
You begin to enter "4" => this would be valid, no input blocked.
Same for "47"
As soon as you enter "47. => validation fails, input blocked.
I was thinking maybe it's possible to enter "4711" first and then the "." in between but for some reason this doesn't seem to work, too... Maybe this is a bug?
Anyways, you can take a look at this stackblitz example for better understanding.
I've also prepared an example of using ValidateOnly and in addition to that restrict the input to only numbers using keyDown event

Setting selected entry using helper.options?

Im am using Play 2.0.4 and
helper.options(myitems)
in my template (inside of a helper.select)
In this case, how can I define the default selected entry, which shall be one entry out of myitems? Thanks for any hint!
A little bit more about my case:
Imagine a news archive, showing all news titles. This news archive uses pagination, pagination uses GET to pass the next/previous page number.
The play framework however will only correctly select the currently selected "select" item (here: news category) when a POST request was used - while pagination uses GET!
Intended behaviour: While a filter is applied / a specific news category is selected, this shall always be visible to the user by preselecting the currently selected news category in the "select" form.
A "screenshot" for illustration:
So, anyone having a good idea on how to cope with this problem? Any way to tell Play manually which entry from the "select" form it shall select? '_default always adds a new entry instead of selecting one out of the given options ): Would be great, if one wouldn't have to build the complete "select" form manually.
Try passing '_default option to select helper:
#import views.html.helper._
#select(form("email"), options(List("first", "third")), '_default -> "second")
It seems, unfortunately, the only way to figure it out is to look up the source.
Update:
Specifying _default property doesn't set selected attribute on option tag. It looks like the only way to preselect entry is to pass prefilled form to the template. For example, suppose you have following form:
case class RegInfo(email: String, color: String)
private val registrationForm = Form(
mapping(
"email" → email,
"color" → nonEmptyText(minLength = 5, maxLength = 32)
)(RegInfo.apply)(RegInfo.unapply)
)
Then in the action prefill form before passing to the view:
def create = Action {
Ok(html.create(registrationForm.fill(RegInfo("user#qwe.com", "blue"))))
}
Then in template use helper:
#select(form("color"), options(List("red", "green", "blue")))
And value will be preselected.
Ended up with the pragmatic approach:
<select id="myfield" name="myfield" >
<option class="blank" value="">-- All items --</option>
#for((key, value) <- MyModel.options) {
#if(key == GETValuePassedToTemplate) {
<option value="#key" selected>#value</option>
} else {
<option value="#key">#value</option>
}
}
</select>
Still wondering if there is a better option / way to do it.
Actually, there is a nicer solution to it. If you call the template having the form partially bound you will achieve your goal. Here's the code for your controller:
Ok(views.html.myForm(myForm.bind(
Map("fieldName1" -> "value1",
"fieldName2" -> "value2"))))
Make sure you map fieldnames to the values of the options you want pre-selected.
Still wondering if there is a better option / way to do it.
Well, if your not hell-bent on using play to solve this particular problem, you could always solve it using JavaScript and jQuery:
$(function () {
$('#yourSelect_id').val(5);
}
Where your select options each has values and the one option you whish to pre select has value 5.

how can i match html tags with no id with deface

Trying to add a column to a table in the configuration menu, the table has a empty <th> </th> just for looks, but when i add the column, it adds it after this so looks ugly, adding it with this
Deface::Override.new(:virtual_path => "spree/admin/user_groups/index",
:name => "minimum_order_column",
:insert_after => "code[erb-loud]:contains('description')",
:partial => "spree/admin/user_groups/minimum_order_column")
first weird thing is that it adds it after that empty th, but seems like a easy fix if I could just remove it
admin/user_groups is from spree_user_groups
Deface uses CSS selectors in general to do it's dirty work.
You should be able to do th[3] or th:last to find that <th>
http://deface.heroku.com/ is a great tool to help in testing selectors.

Zend Regex Route help

I am trying to create a Zend_Controller_Router_Route_Regex route to process URLs in the following form:
search?q=chicken/page=2 where the first regex subpattern would be chicken and second one would be 2. As for the second part where page=2, I want to make it optional if it is the first page, that is page=1. So another url such as search?q=chicken would also be valid and is equivalent to search?q=chicken/page=1.
Here is my attempt albeit without any success, but to give you a better picture of what I am trying to do.
$route = new Zend_Controller_Router_Route_Regex(
'search\?q=([a-zA-Z0-9]+)(?:/page=(\d+))',
array(
'page'=> '1',
'module' => 'default',
'controller' => 'search',
'action' => 'index' ),
array( 1 => 'query', 2 => 'page' ),
'search?=%s/page=%d');
$router->addRoute('search', $route);
The problem here is I cant compose the correct regex.
Thanks in advance.
EDIT #1
The correct regex, as pointed out by MA4, is 'search\?q=([a-zA-Z0-9]+)(?:/page=(\d+))?'
The real problem is pointed by Darryl. Here is a little bit more info to put things into perspective.
My search text box and button
<form action="/search" method="get">
<input type="text" name="q" />
<input type="submit" value="Search" />
</form>
Every time I press the search button, I get the search?q=[text] request. How do I force it to go through the regex match route?
Here is what i want to do, however the code does not work
if($this->getRequest()->getParam('query')){
// redirect success
} else {
$url = "search?q=" . $this->_getParam('q');
$this->_redirect(route('search'), array('code' => 301 ));
}
/search?q=chicken/page=2 is not parsable by Zend Frameworks' router. The router will only see /search.
The router relies on the Path Info provided by the server and anything after the ? is the query string.
You would need to use a path such as this:
/search/[word] (default page 1)
/search/[word]/[page]
In which case your regex would become much simpler.
make the second part optionnal by adding a ? after it:
search\?q=([a-zA-Z0-9]+)(?:/page=(\d+))?