In xlsx file, limit "add new instances" on linked_table

In xlsx file, I have a input has type integer. When I type a number greater
than 0
, I will go to next screen and can link a lot of tables by

  • linked_table*.
    So it's a problem,example : I have 2 student profiles so I type number 2,
    in next screen, I can link more tables than 2, button "Add new Instances"
    always show.
    I want If I type 2, in next screen, I can add 2 link_table.
    If linked_table has 2, button "Add new Instances" will hide.
    If linked_table just 0 or 1 , button "Add new Instances" will show for me
    to add more.

I attached example I made .

Thanks so much

Sorry for my bad english.

students_form.xlsx (48.3 KB)

I'm not sure I completely understand the question. I believe you are
asking how to conditionally hide the "Add new instances" button based on
the variable that you are using to link the students table to the
student_profile table. I've attached two xlsx files that do this based on
your students_form.xlsx example. The students.xlsx file corresponds to
your students_form.xlsx file. The student_profile.xlsx form is used to
define the fields in the student_profile table. Particularly, you will
want to look at the display.hide_add_instances field in the queries
worksheet of the students xlsx file. If this doesn't answer your question
or if you have more questions, feel free to post another question.

Clarice

student_profile.xlsx (13.2 KB)

students.xlsx (45.8 KB)

··· On Wed, Nov 11, 2015 at 10:11 PM, Lê Tuấn Tài wrote:

In xlsx file, I have a input has type integer. When I type a number greater
than 0
, I will go to next screen and can link a lot of tables by

  • linked_table*.
    So it's a problem,example : I have 2 student profiles so I type number 2,
    in next screen, I can link more tables than 2, button "Add new
    Instances"
    always show.
    I want If I type 2, in next screen, I can add 2 link_table.
    If linked_table has 2, button "Add new Instances" will hide.
    If linked_table just 0 or 1 , button "Add new Instances" will show for
    me to add more.

I attached example I made .

Thanks so much

Sorry for my bad english.

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thanks for the display.hide_add_instances field, first time I see it :).
But with your example, It couldnt work like I want.

I found display.hide_add_instances
in framework\survey\templates\linked_table.handlebars file and found
{{#unless display.hide_add_instance}}, it cover button Add new Instance
{{#each instances}}, it cover list linked tables
So I think, If can get the size of instances list and "this size greater
than number was limited by me, Add new instance button will hide" .

But It's problem, I don't know how to get size of instances list. Can you
help me?

Thanks :slight_smile:

P/s : Sorry for long time no reply, I was lost internet connection :frowning:

Vào 02:11:46 UTC+7 Thứ Sáu, ngày 13 tháng 11 năm 2015, clarice larson đã
viết:

linked_table.handlebars (1.1 KB)

··· > > I'm not sure I completely understand the question. I believe you are > asking how to conditionally hide the "Add new instances" button based on > the variable that you are using to link the students table to the > student_profile table. I've attached two xlsx files that do this based on > your students_form.xlsx example. The students.xlsx file corresponds to > your students_form.xlsx file. The student_profile.xlsx form is used to > define the fields in the student_profile table. Particularly, you will > want to look at the display.hide_add_instances field in the queries > worksheet of the students xlsx file. If this doesn't answer your question > or if you have more questions, feel free to post another question. > > Clarice > > On Wed, Nov 11, 2015 at 10:11 PM, Lê Tuấn Tài <tai...@dtt.vn wrote: > >> In xlsx file, I have a input has type *integer*. When I type a number *greater >> than 0*, I will go to next screen and can link a lot of tables by >> * linked_table*. >> So it's a problem,example : I have 2 student profiles so I type >> number 2, in next screen, I can link more tables than 2, button *"Add >> new Instances"* always show. >> I want If I type 2, in next screen, I can add 2 link_table. >> If linked_table has 2, button *"Add new Instances"* will hide. >> If linked_table just 0 or 1 , button *"Add new Instances"* will show for >> me to add more. >> >> I attached example I made . >> >> >> Thanks so much >> >> Sorry for my bad english. >> >> >> >

I understand the issue now. The best way to do this is with a custom
prompt type. The handlebars and JavaScript file for the custom prompt type
should be placed in the same directory as the Excel file that is using
them. I've included a zip file with an example of how to do this. In the
example that I've provided, the custom prompt type is called
'custom_linked_table' and the students.xlsx file uses this prompt type.
The 'custom_linked_table' prompt extends the linked_table prompt type to
only display the add instance button if the current number of instances is
less than the specified limit. I've listed the files included in the zip
and given a description of the things you will want to notice.

students/forms/students/students.xlsx - The Excel file that makes use of
the 'custom_linked_table' prompt type. The prompt_types worksheet has been
added to this Excel file to include the definition of the
'custom_linked_table'.

student_profile/forms/student_profile/student_profile.xlsx - This Excel
file defines the table that the students survey links to.

students/forms/students/custom_linked_table.handlebars - This is the html
associated with the 'custom_linked_table' prompt. This file has been
modified to from the original linked_table.handlebars to use
'custom_hide_add_instance' to determine whether to show the add button.

students/forms/students/customPromptTypes.js - This is the JavaScript file
associated with the 'custom_linked_table' prompt. In particular, lines 53

  • 58 have the logic for determining when to show the add instance button.
    Right now the code is set to not show the add button if more than two
    instances exist. You can change this limit by changing the value of
    that.renderContext.max_size.

Clarice

student_example.zip (59.1 KB)

··· On Wed, Nov 18, 2015 at 8:43 PM, Lê Tuấn Tài wrote:

Thanks for the display.hide_add_instances field, first time I see it :).
But with your example, It couldnt work like I want.

I found display.hide_add_instances
in framework\survey\templates\linked_table.handlebars file and found
{{#unless display.hide_add_instance}}, it cover button Add new Instance
{{#each instances}}, it cover list linked tables
So I think, If can get the size of instances list and "this size greater
than number was limited by me, Add new instance button will hide" .

But It's problem, I don't know how to get size of instances list. Can you
help me?

Thanks :slight_smile:

P/s : Sorry for long time no reply, I was lost internet connection :frowning:

Vào 02:11:46 UTC+7 Thứ Sáu, ngày 13 tháng 11 năm 2015, clarice larson đã
viết:

I'm not sure I completely understand the question. I believe you are
asking how to conditionally hide the "Add new instances" button based on
the variable that you are using to link the students table to the
student_profile table. I've attached two xlsx files that do this based on
your students_form.xlsx example. The students.xlsx file corresponds to
your students_form.xlsx file. The student_profile.xlsx form is used to
define the fields in the student_profile table. Particularly, you will
want to look at the display.hide_add_instances field in the queries
worksheet of the students xlsx file. If this doesn't answer your question
or if you have more questions, feel free to post another question.

Clarice

On Wed, Nov 11, 2015 at 10:11 PM, Lê Tuấn Tài tai...@dtt.vn wrote:

In xlsx file, I have a input has type integer. When I type a number greater
than 0
, I will go to next screen and can link a lot of tables by

  • linked_table*.
    So it's a problem,example : I have 2 student profiles so I type
    number 2, in next screen, I can link more tables than 2, button "Add
    new Instances"
    always show.
    I want If I type 2, in next screen, I can add 2 link_table.
    If linked_table has 2, button "Add new Instances" will hide.
    If linked_table just 0 or 1 , button "Add new Instances" will show
    for me to add more.

I attached example I made .

Thanks so much

Sorry for my bad english.

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thank you so much. It helped me a lot.
But only one issue now. I try so much but not work.
In file customPromptTypes.js, I want set dynamically value
to that.renderContext.max_size, by that.renderContext.max_size =
that.display.max_size;
(line 18). But it always get a text I setted, not
value of this and you can see log in line 68.
In file students.xlsx, I set data('NumProfile') on col display.max_size
(line 7).

Can you help me how to set value dynamically to that.renderContext.max_size
?

Thanks

Vào 10:56:01 UTC+7 Thứ Sáu, ngày 20 tháng 11 năm 2015, clarice larson đã
viết:

customPromptTypes.js (4.36 KB)

students.xlsx (44 KB)

··· > > I understand the issue now. The best way to do this is with a custom > prompt type. The handlebars and JavaScript file for the custom prompt type > should be placed in the same directory as the Excel file that is using > them. I've included a zip file with an example of how to do this. In the > example that I've provided, the custom prompt type is called > 'custom_linked_table' and the students.xlsx file uses this prompt type. > The 'custom_linked_table' prompt extends the linked_table prompt type to > only display the add instance button if the current number of instances is > less than the specified limit. I've listed the files included in the zip > and given a description of the things you will want to notice. > > students/forms/students/students.xlsx - The Excel file that makes use of > the 'custom_linked_table' prompt type. The prompt_types worksheet has been > added to this Excel file to include the definition of the > 'custom_linked_table'. > > student_profile/forms/student_profile/student_profile.xlsx - This Excel > file defines the table that the students survey links to. > > students/forms/students/custom_linked_table.handlebars - This is the html > associated with the 'custom_linked_table' prompt. This file has been > modified to from the original linked_table.handlebars to use > 'custom_hide_add_instance' to determine whether to show the add button. > > students/forms/students/customPromptTypes.js - This is the JavaScript file > associated with the 'custom_linked_table' prompt. In particular, lines 53 > - 58 have the logic for determining when to show the add instance button. > Right now the code is set to not show the add button if more than two > instances exist. You can change this limit by changing the value of > that.renderContext.max_size. > > Clarice > > On Wed, Nov 18, 2015 at 8:43 PM, Lê Tuấn Tài <tai...@dtt.vn > wrote: > >> Thanks for the display.hide_add_instances field, first time I see it :). >> But with your example, It couldnt work like I want. >> >> I found display.hide_add_instances >> in framework\survey\templates\linked_table.handlebars file and found >> {{#unless display.hide_add_instance}}, it cover button Add new Instance >> {{#each instances}}, it cover list linked tables >> So I think, If can get the size of instances list and "this size greater >> than number was limited by me, Add new instance button will hide" . >> >> But It's problem, I don't know how to get size of instances list. Can >> you help me? >> >> Thanks :) >> >> P/s : Sorry for long time no reply, I was lost internet connection :( >> >> Vào 02:11:46 UTC+7 Thứ Sáu, ngày 13 tháng 11 năm 2015, clarice larson đã >> viết: >>> >>> I'm not sure I completely understand the question. I believe you are >>> asking how to conditionally hide the "Add new instances" button based on >>> the variable that you are using to link the students table to the >>> student_profile table. I've attached two xlsx files that do this based on >>> your students_form.xlsx example. The students.xlsx file corresponds to >>> your students_form.xlsx file. The student_profile.xlsx form is used to >>> define the fields in the student_profile table. Particularly, you will >>> want to look at the display.hide_add_instances field in the queries >>> worksheet of the students xlsx file. If this doesn't answer your question >>> or if you have more questions, feel free to post another question. >>> >>> Clarice >>> >>> On Wed, Nov 11, 2015 at 10:11 PM, Lê Tuấn Tài wrote: >>> >>>> In xlsx file, I have a input has type *integer*. When I type a number *greater >>>> than 0*, I will go to next screen and can link a lot of tables by >>>> * linked_table*. >>>> So it's a problem,example : I have 2 student profiles so I type >>>> number 2, in next screen, I can link more tables than 2, button *"Add >>>> new Instances"* always show. >>>> I want If I type 2, in next screen, I can add 2 link_table. >>>> If linked_table has 2, button *"Add new Instances"* will hide. >>>> If linked_table just 0 or 1 , button *"Add new Instances"* will show >>>> for me to add more. >>>> >>>> I attached example I made . >>>> >>>> >>>> Thanks so much >>>> >>>> Sorry for my bad english. >>>> >>>> >>>> >>> >> >

The way to do this would be to create a column_types worksheet where you
set the column_type of display.max_size to formula. However, when I
attempted to do this, I found a bug in the XLSXConverter that caused the
creation of two invalid column_types - _row_num and rowNum. To work
around this, I hand edited the formDef.json for the student.xlsx file and
deleted these two column_types (In my original file, these lines were 132
and 133.). In the attached zip file, you will find the student.xlsx file,
the hand edited formDef.json, and formDef.json.orig (the original file
before hand editing). I also needed to edit line 54 of the
customPromptTypes.js file to ensure that the formula defined in
display.max_size was evaluated for the comparison operation. Investigating
this issue helped to identify a bug that we will be sure to correct in our
next release so thank you for your question.

Clarice

edited_student_example.zip (41.8 KB)

··· On Mon, Nov 23, 2015 at 12:38 AM, Lê Tuấn Tài wrote:

Thank you so much. It helped me a lot.
But only one issue now. I try so much but not work.
In file customPromptTypes.js, I want set dynamically value
to that.renderContext.max_size, by that.renderContext.max_size =
that.display.max_size;
(line 18). But it always get a text I setted, not
value of this and you can see log in line 68.
In file students.xlsx, I set data('NumProfile') on col display.max_size
(line 7).

Can you help me how to set value dynamically to
that.renderContext.max_size ?

Thanks

Vào 10:56:01 UTC+7 Thứ Sáu, ngày 20 tháng 11 năm 2015, clarice larson đã
viết:

I understand the issue now. The best way to do this is with a custom
prompt type. The handlebars and JavaScript file for the custom prompt type
should be placed in the same directory as the Excel file that is using
them. I've included a zip file with an example of how to do this. In the
example that I've provided, the custom prompt type is called
'custom_linked_table' and the students.xlsx file uses this prompt type.
The 'custom_linked_table' prompt extends the linked_table prompt type to
only display the add instance button if the current number of instances is
less than the specified limit. I've listed the files included in the zip
and given a description of the things you will want to notice.

students/forms/students/students.xlsx - The Excel file that makes use of
the 'custom_linked_table' prompt type. The prompt_types worksheet has been
added to this Excel file to include the definition of the
'custom_linked_table'.

student_profile/forms/student_profile/student_profile.xlsx - This Excel
file defines the table that the students survey links to.

students/forms/students/custom_linked_table.handlebars - This is the html
associated with the 'custom_linked_table' prompt. This file has been
modified to from the original linked_table.handlebars to use
'custom_hide_add_instance' to determine whether to show the add button.

students/forms/students/customPromptTypes.js - This is the JavaScript
file associated with the 'custom_linked_table' prompt. In particular,
lines 53 - 58 have the logic for determining when to show the add instance
button. Right now the code is set to not show the add button if more than
two instances exist. You can change this limit by changing the value of
that.renderContext.max_size.

Clarice

On Wed, Nov 18, 2015 at 8:43 PM, Lê Tuấn Tài tai...@dtt.vn wrote:

Thanks for the display.hide_add_instances field, first time I see it :).
But with your example, It couldnt work like I want.

I found display.hide_add_instances
in framework\survey\templates\linked_table.handlebars file and found
{{#unless display.hide_add_instance}}, it cover button Add new Instance
{{#each instances}}, it cover list linked tables
So I think, If can get the size of instances list and "this size greater
than number was limited by me, Add new instance button will hide" .

But It's problem, I don't know how to get size of instances list. Can
you help me?

Thanks :slight_smile:

P/s : Sorry for long time no reply, I was lost internet connection :frowning:

Vào 02:11:46 UTC+7 Thứ Sáu, ngày 13 tháng 11 năm 2015, clarice larson đã
viết:

I'm not sure I completely understand the question. I believe you are
asking how to conditionally hide the "Add new instances" button based on
the variable that you are using to link the students table to the
student_profile table. I've attached two xlsx files that do this based on
your students_form.xlsx example. The students.xlsx file corresponds to
your students_form.xlsx file. The student_profile.xlsx form is used to
define the fields in the student_profile table. Particularly, you will
want to look at the display.hide_add_instances field in the queries
worksheet of the students xlsx file. If this doesn't answer your question
or if you have more questions, feel free to post another question.

Clarice

On Wed, Nov 11, 2015 at 10:11 PM, Lê Tuấn Tài tai...@dtt.vn wrote:

In xlsx file, I have a input has type integer. When I type a number greater
than 0
, I will go to next screen and can link a lot of tables by

  • linked_table*.
    So it's a problem,example : I have 2 student profiles so I type
    number 2, in next screen, I can link more tables than 2, button "Add
    new Instances"
    always show.
    I want If I type 2, in next screen, I can add 2 link_table.
    If linked_table has 2, button "Add new Instances" will hide.
    If linked_table just 0 or 1 , button "Add new Instances" will show
    for me to add more.

I attached example I made .

Thanks so much

Sorry for my bad english.

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

wow, thank so much. excellence :). And I found another way, too.

  • In customPromptTypes.js , line 18, I change to that.renderContext.max_size
    = ((that.display.max_size != null) ?
    database.getDataValue(that.display.max_size) : 0);
  • In students.xlsx, a row has custom_linked_table, I set column
    display.max_size is NumProfile.
    So it will get a value of NumProfile, not a text.

Thanks your base, it help me can resolved it :slight_smile:

Vào 06:27:10 UTC+7 Thứ Ba, ngày 24 tháng 11 năm 2015, clarice larson đã
viết:

customPromptTypes.js (4.44 KB)

students.xlsx (44 KB)

··· > > The way to do this would be to create a column_types worksheet where you > set the column_type of display.max_size to formula. However, when I > attempted to do this, I found a bug in the XLSXConverter that caused the > creation of two invalid column_types - _row_num and __rowNum__. To work > around this, I hand edited the formDef.json for the student.xlsx file and > deleted these two column_types (In my original file, these lines were 132 > and 133.). In the attached zip file, you will find the student.xlsx file, > the hand edited formDef.json, and formDef.json.orig (the original file > before hand editing). I also needed to edit line 54 of the > customPromptTypes.js file to ensure that the formula defined in > display.max_size was evaluated for the comparison operation. Investigating > this issue helped to identify a bug that we will be sure to correct in our > next release so thank you for your question. > > Clarice > > On Mon, Nov 23, 2015 at 12:38 AM, Lê Tuấn Tài <tai...@dtt.vn wrote: > >> Thank you so much. It helped me a lot. >> But only one issue now. I try so much but not work. >> In file *customPromptTypes.js,* I want set dynamically value >> to that.renderContext.max_size, by *that.renderContext.max_size = >> that.display.max_size;* (line 18). But it always get a text I setted, >> not value of this and you can see log in line 68. >> In file *students.xlsx*, I set data('NumProfile') on col >> display.max_size (line 7). >> >> Can you help me how to set value dynamically to >> that.renderContext.max_size ? >> >> Thanks >> >> Vào 10:56:01 UTC+7 Thứ Sáu, ngày 20 tháng 11 năm 2015, clarice larson đã >> viết: >>> >>> I understand the issue now. The best way to do this is with a custom >>> prompt type. The handlebars and JavaScript file for the custom prompt type >>> should be placed in the same directory as the Excel file that is using >>> them. I've included a zip file with an example of how to do this. In the >>> example that I've provided, the custom prompt type is called >>> 'custom_linked_table' and the students.xlsx file uses this prompt type. >>> The 'custom_linked_table' prompt extends the linked_table prompt type to >>> only display the add instance button if the current number of instances is >>> less than the specified limit. I've listed the files included in the zip >>> and given a description of the things you will want to notice. >>> >>> students/forms/students/students.xlsx - The Excel file that makes use of >>> the 'custom_linked_table' prompt type. The prompt_types worksheet has been >>> added to this Excel file to include the definition of the >>> 'custom_linked_table'. >>> >>> student_profile/forms/student_profile/student_profile.xlsx - This Excel >>> file defines the table that the students survey links to. >>> >>> students/forms/students/custom_linked_table.handlebars - This is the >>> html associated with the 'custom_linked_table' prompt. This file has been >>> modified to from the original linked_table.handlebars to use >>> 'custom_hide_add_instance' to determine whether to show the add button. >>> >>> students/forms/students/customPromptTypes.js - This is the JavaScript >>> file associated with the 'custom_linked_table' prompt. In particular, >>> lines 53 - 58 have the logic for determining when to show the add instance >>> button. Right now the code is set to not show the add button if more than >>> two instances exist. You can change this limit by changing the value of >>> that.renderContext.max_size. >>> >>> Clarice >>> >>> On Wed, Nov 18, 2015 at 8:43 PM, Lê Tuấn Tài wrote: >>> >>>> Thanks for the display.hide_add_instances field, first time I see it >>>> :). But with your example, It couldnt work like I want. >>>> >>>> I found display.hide_add_instances >>>> in framework\survey\templates\linked_table.handlebars file and found >>>> {{#unless display.hide_add_instance}}, it cover button Add new Instance >>>> {{#each instances}}, it cover list linked tables >>>> So I think, If can get the size of instances list and "this size >>>> greater than number was limited by me, Add new instance button will hide" . >>>> >>>> But It's problem, I don't know how to get size of instances list. Can >>>> you help me? >>>> >>>> Thanks :) >>>> >>>> P/s : Sorry for long time no reply, I was lost internet connection :( >>>> >>>> Vào 02:11:46 UTC+7 Thứ Sáu, ngày 13 tháng 11 năm 2015, clarice larson >>>> đã viết: >>>>> >>>>> I'm not sure I completely understand the question. I believe you are >>>>> asking how to conditionally hide the "Add new instances" button based on >>>>> the variable that you are using to link the students table to the >>>>> student_profile table. I've attached two xlsx files that do this based on >>>>> your students_form.xlsx example. The students.xlsx file corresponds to >>>>> your students_form.xlsx file. The student_profile.xlsx form is used to >>>>> define the fields in the student_profile table. Particularly, you will >>>>> want to look at the display.hide_add_instances field in the queries >>>>> worksheet of the students xlsx file. If this doesn't answer your question >>>>> or if you have more questions, feel free to post another question. >>>>> >>>>> Clarice >>>>> >>>>> On Wed, Nov 11, 2015 at 10:11 PM, Lê Tuấn Tài wrote: >>>>> >>>>>> In xlsx file, I have a input has type *integer*. When I type a >>>>>> number *greater than 0*, I will go to next screen and can link a lot >>>>>> of tables by* linked_table*. >>>>>> So it's a problem,example : I have 2 student profiles so I type >>>>>> number 2, in next screen, I can link more tables than 2, button *"Add >>>>>> new Instances"* always show. >>>>>> I want If I type 2, in next screen, I can add 2 link_table. >>>>>> If linked_table has 2, button *"Add new Instances"* will hide. >>>>>> If linked_table just 0 or 1 , button *"Add new Instances"* will show >>>>>> for me to add more. >>>>>> >>>>>> I attached example I made . >>>>>> >>>>>> >>>>>> Thanks so much >>>>>> >>>>>> Sorry for my bad english. >>>>>> >>>>>> >>>>>> >>>>> >>>> >>> >

I'm glad that you figured out an alternative. Thank you for sharing this
solution.

Clarice

··· On Mon, Nov 23, 2015 at 7:02 PM, Lê Tuấn Tài wrote:

wow, thank so much. excellence :). And I found another way, too.

  • In customPromptTypes.js , line 18, I change to that.renderContext.max_size
    = ((that.display.max_size != null) ?
    database.getDataValue(that.display.max_size) : 0);
  • In students.xlsx, a row has custom_linked_table, I set column
    display.max_size is NumProfile.
    So it will get a value of NumProfile, not a text.

Thanks your base, it help me can resolved it :slight_smile:

Vào 06:27:10 UTC+7 Thứ Ba, ngày 24 tháng 11 năm 2015, clarice larson đã
viết:

The way to do this would be to create a column_types worksheet where you
set the column_type of display.max_size to formula. However, when I
attempted to do this, I found a bug in the XLSXConverter that caused the
creation of two invalid column_types - _row_num and rowNum. To work
around this, I hand edited the formDef.json for the student.xlsx file and
deleted these two column_types (In my original file, these lines were 132
and 133.). In the attached zip file, you will find the student.xlsx file,
the hand edited formDef.json, and formDef.json.orig (the original file
before hand editing). I also needed to edit line 54 of the
customPromptTypes.js file to ensure that the formula defined in
display.max_size was evaluated for the comparison operation. Investigating
this issue helped to identify a bug that we will be sure to correct in our
next release so thank you for your question.

Clarice

On Mon, Nov 23, 2015 at 12:38 AM, Lê Tuấn Tài tai...@dtt.vn wrote:

Thank you so much. It helped me a lot.
But only one issue now. I try so much but not work.
In file customPromptTypes.js, I want set dynamically value
to that.renderContext.max_size, by that.renderContext.max_size =
that.display.max_size;
(line 18). But it always get a text I setted,
not value of this and you can see log in line 68.
In file students.xlsx, I set data('NumProfile') on col
display.max_size (line 7).

Can you help me how to set value dynamically to
that.renderContext.max_size ?

Thanks

Vào 10:56:01 UTC+7 Thứ Sáu, ngày 20 tháng 11 năm 2015, clarice larson đã
viết:

I understand the issue now. The best way to do this is with a custom
prompt type. The handlebars and JavaScript file for the custom prompt type
should be placed in the same directory as the Excel file that is using
them. I've included a zip file with an example of how to do this. In the
example that I've provided, the custom prompt type is called
'custom_linked_table' and the students.xlsx file uses this prompt type.
The 'custom_linked_table' prompt extends the linked_table prompt type to
only display the add instance button if the current number of instances is
less than the specified limit. I've listed the files included in the zip
and given a description of the things you will want to notice.

students/forms/students/students.xlsx - The Excel file that makes use
of the 'custom_linked_table' prompt type. The prompt_types worksheet has
been added to this Excel file to include the definition of the
'custom_linked_table'.

student_profile/forms/student_profile/student_profile.xlsx - This Excel
file defines the table that the students survey links to.

students/forms/students/custom_linked_table.handlebars - This is the
html associated with the 'custom_linked_table' prompt. This file has been
modified to from the original linked_table.handlebars to use
'custom_hide_add_instance' to determine whether to show the add button.

students/forms/students/customPromptTypes.js - This is the JavaScript
file associated with the 'custom_linked_table' prompt. In particular,
lines 53 - 58 have the logic for determining when to show the add instance
button. Right now the code is set to not show the add button if more than
two instances exist. You can change this limit by changing the value of
that.renderContext.max_size.

Clarice

On Wed, Nov 18, 2015 at 8:43 PM, Lê Tuấn Tài tai...@dtt.vn wrote:

Thanks for the display.hide_add_instances field, first time I see it
:). But with your example, It couldnt work like I want.

I found display.hide_add_instances
in framework\survey\templates\linked_table.handlebars file and found
{{#unless display.hide_add_instance}}, it cover button Add new Instance
{{#each instances}}, it cover list linked tables
So I think, If can get the size of instances list and "this size
greater than number was limited by me, Add new instance button will hide" .

But It's problem, I don't know how to get size of instances list. Can
you help me?

Thanks :slight_smile:

P/s : Sorry for long time no reply, I was lost internet connection :frowning:

Vào 02:11:46 UTC+7 Thứ Sáu, ngày 13 tháng 11 năm 2015, clarice larson
đã viết:

I'm not sure I completely understand the question. I believe you are
asking how to conditionally hide the "Add new instances" button based on
the variable that you are using to link the students table to the
student_profile table. I've attached two xlsx files that do this based on
your students_form.xlsx example. The students.xlsx file corresponds to
your students_form.xlsx file. The student_profile.xlsx form is used to
define the fields in the student_profile table. Particularly, you will
want to look at the display.hide_add_instances field in the queries
worksheet of the students xlsx file. If this doesn't answer your question
or if you have more questions, feel free to post another question.

Clarice

On Wed, Nov 11, 2015 at 10:11 PM, Lê Tuấn Tài tai...@dtt.vn wrote:

In xlsx file, I have a input has type integer. When I type a
number greater than 0, I will go to next screen and can link a
lot of tables by* linked_table*.
So it's a problem,example : I have 2 student profiles so I type
number 2, in next screen, I can link more tables than 2, button "Add
new Instances"
always show.
I want If I type 2, in next screen, I can add 2 link_table.
If linked_table has 2, button "Add new Instances" will hide.
If linked_table just 0 or 1 , button "Add new Instances" will
show for me to add more.

I attached example I made .

Thanks so much

Sorry for my bad english.

--
You received this message because you are subscribed to the Google Groups
"ODK Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.