Links and insert problems of list

LabKey Support Forum
Links and insert problems of list feifei bao  2015-04-07 07:39
Status: Closed
 
Hi,

I'm new to LabKey. Right now I've come across some problems I hope someone can help me. In a page, I imported a list. When I click "INSERT NEW", I want it links to another new wiki page I created rather than the Labkey default page. I can not find the right place to change it.

The new wiki page is a custom form which is consistent with the content in the list. Once I click the "submit" button I can insert a new row to the list. For this part, do I need to use the LABKEY.Query.insertRows() API call to insert rows?

Thank you very much.

Feifei
 
 
Jon (LabKey DevOps) responded:  2015-04-07 13:43
Hi FeiFei,

So to answer your two questions:

1. If you have a wiki page that is going to be used in lieu of the normal default Insert New page for your list, you will have to update the XML Metadata of that list to redirect your Insert New button to your wiki form.

Now, it should be using <insertUrl> as described here: https://www.labkey.org/wiki/home/Documentation/page.view?name=tableMetadata

However, I'm currently seeing an issue with using that XML tag, so as an alternative solution, I would recommend you use the buttonBarOptions instead to create an Insert New button that will point to your wiki form. See the example code below where I created a list called "TestList" in my own system. My Insert New button in this case points to the website Google, but you would replace the Target with your wiki page URL instead.

<tables xmlns="http://labkey.org/data/xml">
  <table tableName="TestList" tableDbType="NOT_IN_DB">
    <columns></columns>
    <buttonBarOptions includeStandardButtons="true">
      <item text="Insert New">
        <target>http://www.google.com</target>
      </item>
    </buttonBarOptions>
  </table>
</tables>

Alternatively, if your list is being embedded in a wiki page as a QueryWebPart via JavaScript, another solution would be to use the config.insertURL option in your API call and use that to dictate your Insert New button.

https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.QueryWebPart.html

2. And you are correct. Within your wiki page that you've turned into a submission form, you will have to use the the LABKEY.Query.insertRows() API call to insert the rows to update your list.

https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.Query.html#.insertRows

Regards,

Jon
 
feifei bao responded:  2015-04-08 09:19
Thank you so much for your detailed explanation. I try to use the buttonBarOptions. It works!

For the imported list, I created some search boxes in the page. How can I get the dynamic results of the list after search? For example, I input the specific participant ID or sample ID in the search box and it can show the updated result list. I can only find the static query based on the table. Do you have any suggestions about the dynamic queries? Thanks a lot.

Feifei
 
Jon (LabKey DevOps) responded:  2015-04-08 12:09
Hi Feifei,

I'm not sure I quite understand your follow-up question. Are you saying the search box you added does or doesn't actually work?

Your search box would have to pipe into your query as a filter and would have to re-run the query upon submitting a search and reloading the table or the entire page while using the new query.

Regards,

Jon
 
feifei bao responded:  2015-04-08 12:47
Hi Jon,

I think your understanding is right.

Here is the javascript coding I get from default filter function of list:

<script type="text/javascript">

LABKEY.Query.selectRows({
    requiredVersion: 9.1,
    schemaName: 'study',
    queryName: 'Demographics',
    columns: 'ParticipantId,date,Start Date,Height (inches),Gender,Country,Group Assignment,Status of Infection,Comments,Treatment Group',
    filterArray: [LABKEY.Filter.create('Height (inches)', '58;57', LABKEY.Filter.Types.IN),LABKEY.Filter.create('Country', 'USA', LABKEY.Filter.Types.EQUAL)],
    success: onSuccess,
    error: onError
});

But I have no idea about how to create the "filterArray" dynamically based on the input content in the box. Could you please give me an example about how to make the search box pipe into the query as a filter?

Thanks a lot!

Feifei
 
Jon (LabKey DevOps) responded:  2015-04-08 14:23
Hi Feifei,

There's a few different ways to approach this, but what will probably work best is using the push() method to add a new array item to your existing filterArray, using your searchbox.

However, do you only have one search box or multiple boxes? What data are you expected to input into the box? Are there any pre-defined filter parameters that are already in use like what you have listed in your code already or will that information be changed with every search? Your current code has two filters already being used (height and country), will those always stay static?

Regards,

Jon
 
Jon (LabKey DevOps) responded:  2015-04-13 15:49
Hi Feifei,

It's been some time since we've heard back from you, so we're going to set this case to closed.

If you have any further questions, please feel free to create a new forum question or re-open this one.

Regards,

Jon