Hi,
I am not sure if this is even possible, so I turn to the magicians here in the forum.
The situation
I have boxes in multiple rows (Reihe, X), depth (Tiefe, Y) that are stacked on top of each other (Ebene, Z).
When I take a box, I can not pull it out of a stack, but I need to remove all boxes that are in front (Y) and all boxes that are on top of the box I want (Z).
The question
How can I use the coordinates (which are saved in the record) in a query for the ajax lookup of possible free locations?
Why
I want to create query for my lookup which does not show the current X-Y combination. This way it will be impossible to select the same row (X) and depth (Y) but simply a different height.
Example
Lets say, I want to pick the red box (coordinates: X=2, Y=1, Z=3). I would need to remove (in this order): (2,3,4) then (2,3,3) then (2,3,2)... at some point I can pick the red box. In my drop down which shows all empty available places, I would not be able to choose (2,1,*) because in this XY combination (21) it makes no sense at the time I am repositioning the box.
Olaf
How to use value from current record in look up query field?
How to use value from current record in look up query field?
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to use value from current record in look up query field?
Hi,
not the solution to the question I asked, but I found a workaround: I can use the before_update hook of that table to compare old (in database saved values) to the new values submitted. If they have the same XY combination I return FALSE in that function and the record will not be changed.
But still: Is it possible to manipulate the ajax lookup field with some value (from the current record)?
Olaf
not the solution to the question I asked, but I found a workaround: I can use the before_update hook of that table to compare old (in database saved values) to the new values submitted. If they have the same XY combination I return FALSE in that function and the record will not be changed.
But still: Is it possible to manipulate the ajax lookup field with some value (from the current record)?
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to use value from current record in look up query field?
Hi Olaf,
if it becomes too complicated when using the built-in options, only, you are always free to add any custom input control to your form.
For example in hooks/TABLENAME.php function TABLENAME_dv():
Then add a script using _header or _footer function or (what I prefer) add TABLENAME-dv.js and fine-tune your new input $j("#whatever"); for example move that new input to a different place.
Hide your original field using $j("#fieldname").closest(".form-group").hide();
If you need to, you can also use AJAX to retrieve values from a server side PHP script and populate the new input on client side.
On every change of your new input, copy the value into the hidden field for example by $j("#db_fieldname").val(myNewInputValue);
You can also do validations on every input change using JavaScript/JQuery and even use AJAX to do server side validation.
Having copied the new-input's value into the (hidden) existing field, you will see it in your $data variable on before/after insert/update.
This hack has helped me a lot when I wanted to add other controls like calendar, signature pad, many-to-many-dropdown, open-street-map map or others. To give an example, yesterday I have added a color picker using that method. The droddown button has been added using JQuery. There is a hidden "color" field which gets updated on every color change:
There is also my many-to-many dropdown combobox in that form. Again: same hack:
Hope this gives you a new idea!
Best,
Jan
PS: To get an similar layout and design, you need to wrap the new inputs into a <div class="form-group"> and add a <label> according to Bootstrap 3 specification https://getbootstrap.com/docs/3.3/css/#forms. Have a look at all the other generated inputs in template-files or in your browser's developer tools and take the HTML-structure as a template for your new form-group.
if it becomes too complicated when using the built-in options, only, you are always free to add any custom input control to your form.
For example in hooks/TABLENAME.php function TABLENAME_dv():
Code: Select all
// new input without any formatting or label, yet
$html .= "<input name=\"whatever\" id=\"whatever\" class=\"form-control\" value=\"test\" />";
Hide your original field using $j("#fieldname").closest(".form-group").hide();
If you need to, you can also use AJAX to retrieve values from a server side PHP script and populate the new input on client side.
On every change of your new input, copy the value into the hidden field for example by $j("#db_fieldname").val(myNewInputValue);
You can also do validations on every input change using JavaScript/JQuery and even use AJAX to do server side validation.
Having copied the new-input's value into the (hidden) existing field, you will see it in your $data variable on before/after insert/update.
This hack has helped me a lot when I wanted to add other controls like calendar, signature pad, many-to-many-dropdown, open-street-map map or others. To give an example, yesterday I have added a color picker using that method. The droddown button has been added using JQuery. There is a hidden "color" field which gets updated on every color change:
There is also my many-to-many dropdown combobox in that form. Again: same hack:
Hope this gives you a new idea!
Best,
Jan
PS: To get an similar layout and design, you need to wrap the new inputs into a <div class="form-group"> and add a <label> according to Bootstrap 3 specification https://getbootstrap.com/docs/3.3/css/#forms. Have a look at all the other generated inputs in template-files or in your browser's developer tools and take the HTML-structure as a template for your new form-group.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to use value from current record in look up query field?
Hi Jan,
thanks for your suggestion. I am sure the time will come when I need to use a method like this. For now, I am probably fine with the workaround - as I am still not too much into jquery
Olaf
thanks for your suggestion. I am sure the time will come when I need to use a method like this. For now, I am probably fine with the workaround - as I am still not too much into jquery
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to use value from current record in look up query field?
Sorry, I did not see that you have already answered your request by yourself.
Anyway, hope this idea will help anyone!
Best,
Jan
Anyway, hope this idea will help anyone!
Best,
Jan
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to use value from current record in look up query field?
Hi Jan,
yes, I am thankful for your answer as it proposes a great way to intercept AG standard behavior.
Olaf
yes, I am thankful for your answer as it proposes a great way to intercept AG standard behavior.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: How to use value from current record in look up query field?
Hi Jsetzer,
Do you have a detailed procedure to add "color picker"?
Thanks
Rudy
Do you have a detailed procedure to add "color picker"?
Thanks
Rudy
Re: How to use value from current record in look up query field?
Don't remember which one I have used at that time (2018), there are so many out there:
https://www.jqueryscript.net/tags.php?/color%20picker/
Nowadays I'm using the (modern) browser's built-in (native) options:
Just change attribute
There are two options I'd like to show:
You can do this with standard jQuery like this:
Output
Personally, I did not like the standard design:
1. The select-button takes the full row and
2. You cannot see the selected color very well due to the very thin line
That was the reason why I've coded a wrapper function in my AppGini Helper Javascript Library*, which is easy to use (one-liner) and automatically optimizes the button design according to my personal flavour
2. Using AppGiniHelper Javascript Library*
Output
---
(Sorry, bad quality of compressed image due to size-limitation for attachments here)
https://www.jqueryscript.net/tags.php?/color%20picker/
Nowadays I'm using the (modern) browser's built-in (native) options:
Just change attribute
type="text"
to type="color"
on <input/>
control.There are two options I'd like to show:
- Using standard jQuery
- Using AppGini Helper Javascript Library* * commercial, I am the author
You can do this with standard jQuery like this:
Code: Select all
jQuery("#FIELDNAME").attr("type", "color");
Personally, I did not like the standard design:
1. The select-button takes the full row and
2. You cannot see the selected color very well due to the very thin line
That was the reason why I've coded a wrapper function in my AppGini Helper Javascript Library*, which is easy to use (one-liner) and automatically optimizes the button design according to my personal flavour
2. Using AppGiniHelper Javascript Library*
Code: Select all
// file: hooks/TABLENAME-dv.js
AppGiniHelper.DV.getField("FIELDNAME").toColorPicker();
---
(Sorry, bad quality of compressed image due to size-limitation for attachments here)
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to use value from current record in look up query field?
In case I use your library, I just have to change the input text to color, copy your library.js in the hook directory and create a file TABLENAME-dv.js with the following code
is it possible to see the html color code ( #xxxxxx ) ?
Code: Select all
AppGiniHelper.DV.getField("FIELDNAME").toColorPicker()
Re: How to use value from current record in look up query field?
That's almost correct. Paste file, include script inIn case I use your library, I just have to change the input text to color, copy your library.js in the hook directory and create a file TABLENAME-dv.js with the following code
hooks/header-extras.php
, then start coding in hooks/TABLENAME-dv.js
Instructions here:
http://www.appgini.de/docs/Javascript-L ... start.html
The field itself will show the color as a filled rectangle automatically.
After saving, the field will have a hex value in database, for example "#ff0000"is it possible to see the html color code ( #xxxxxx ) ?
Have a look at the popup window which opens up on click: see the "R G B" at the bottom? On click, this toggles between RGB, HSL and Hex. Next to selecting a color from the color gradients you will also be able to enter color code values in each of these formats manually, for example paste hex-code.
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools
Re: How to use value from current record in look up query field?
Looks good, @brudy, well done!
Kind regards,
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
AppGini 24.10 Revision 1579 + all AppGini Helper tools
<js />
My AppGini Blog:
https://appgini.bizzworxx.de/blog
You can help us helping you:
Please always put code fragments inside
[code]...[/code]
blocks for better readabilityAppGini 24.10 Revision 1579 + all AppGini Helper tools