Jon (LabKey DevOps) responded: |
2015-05-05 16:03 |
Hi Anny,
I'm not quite sure I'm understanding your question. A boolean field will generally display a value of "true" or "false" when it renders the data.
Are you asking that instead of the column showing "True" or "False", but instead you want it to show a checkmark when the data renders?
Regards,
Jon |
|
fb9200 responded: |
2015-05-05 16:15 |
Hi Jon,
You are right. Maybe It can be others rather than boolean filed. I just want to show a checkmark column so users can choose different rows. Also I can make this column update (checked or unchecked) to save the record.
Best regards,
Anny |
|
Jon (LabKey DevOps) responded: |
2015-05-05 23:09 |
Hi Anny,
Thanks for confirming the information.
So it is possible to do this via the query. So this is what I did as an example:
1. Create a list that has a boolean field. I kept mine simple with the fields "Name" (which was text/string field) and "Check" (which is my boolean field).
2. Insert some data and have some of the data set to where the boolean box is checked on for True or blank for false.
3. View your data to confirm that it has both true and false values.
4. Click on Admin > Developer Links > Schema Browser to access the Schema Browser
5. Expand the Lists schema and find your list.
6. Create a new query off of that list.
7. Revise your query to use a CASE WHEN function to identify if something is true or false and use a checkmark. See my code example below:
SELECT ListTest.Name,
CASE WHEN ListTest.Check = false THEN ' ' ELSE '√' END AS Checked
FROM ListTest
8. Execute the query to make sure it looks good and then Save & Finish when done.
The query above says that if the value is false, display a blank space, otherwise display a checkmark.
Regards
Jon |
|
fb9200 responded: |
2015-05-06 08:14 |
Hi Jon,
Thank you for your response. But what your said only shows the static value of blank space or checkmark. Users can not choose checkbox dynamically.
For example, I want to realize the view like javascript "<input type="checkbox">". So users can check or uncheck at anytime.
How can I render query columns like this?
Thank you very much.
Anny |
|
Jon (LabKey DevOps) responded: |
2015-05-06 10:48 |
Hi Anny,
The ability to allow a user to have a checkbox to change the value within the query when it renders is not possible in this case with the current LabKey design.
In order to accomplish what you want, you would have to design a custom module that would have to not only execute that query, but also have it render a checkbox, have that checkbox automatically populate based on the boolean value, then have that those checkboxes tied to a script that would perform an updateRows API call.
Regards,
Jon |
|
jeckels responded: |
2015-05-06 20:18 |
|
|
Will Holtz responded: |
2015-05-12 08:14 |
I was able to get this functionality with a little bit of javascript calling LABKEY.ext.EditorGridPanel(). However, this is a depreciated function. You should be able to get similar results using Ext.grid.EditorGridPanel().
<script type="text/javascript">
var _grid;
Ext.onReady(function(){
_grid = new LABKEY.ext.EditorGridPanel({
store: new LABKEY.ext.Store({
schemaName: 'MySchema',
queryName: 'MyQuery',
}),
renderTo: 'grid',
editable: true
});
});
</script>
<div id='grid'/> |
|