It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Want to create custom Plugin like iDalko(table grid view)

-I want to create custom field module to create table grid like custom table grid .

-I have created custom field using below link -

https://developer.atlassian.com/server/jira/platform/creating-a-custom-field-in-jira/ 

and modify the edit.vm so now its looks like below img. image.png

 

but its not creating an issue .(want to show table on view page after creating issue) . so now what should i do ?

 

2 answers

1 accepted

0 votes
Answer accepted
DPK J Community Leader Jan 15, 2020

@sgoleWelcome to the community!

Have you added custom-field to issue view screen for your project? If not please add it.

Please refer to this documentation - https://confluence.atlassian.com/jirasoftwareserver/configuring-the-issue-detail-view-938845334.html

Moreover, if this doesn't help, there might be some issue with 'view' template of your custom field.

yes i have added custom-field to issue view screen .

Is it possible to create custom table field?

DPK J Community Leader Jan 15, 2020

@sgoleYou can create any type of field, you just need to store it's data in custom tables tough.

can you please help me to get solution of my mentioned problem 

 

DPK J Community Leader Jan 16, 2020

@sgole  for view part you will 'view.vm'

<resource type="velocity" name="view" location="templates/plugins/fields/view/view-basictext.vm"/>
<resource type="velocity" name="edit" location="templates/edit.vm"/> <resource type="velocity" name="xml" location="templates/plugins/fields/xml/xml-basictext.vm"/>

Have you recourse type named 'view', that will be used on view screen of Jira.

I will try to create a sample to help you, but I'll need a day or two for that, running some what busy with official tasks :-)

Like sgole likes this

@DPK J what should be in view.vm exactly i am so confuse what should be in that file ..its ok if you need one or two day ,but please help me with this its been really headache .

DPK J Community Leader Jan 16, 2020

@sgoleI'm on it. I'll surely help you.

Like sgole likes this

@DPK J   im confuse what to write in view.vm . its ok if you need one or two day (try assp ;) ) but please help me with this its been really headache for me .

@DPK J  PS.  i think i need to change "AbstractSingleFieldType" class also .(below is  .java file )

 

package com.example.plugins.tutorial.jira.customfields;

import com.atlassian.jira.issue.customfields.impl.AbstractSingleFieldType;
import com.atlassian.jira.issue.customfields.persistence.PersistenceFieldType;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.JiraImport;
import com.atlassian.jira.issue.customfields.manager.GenericConfigManager;
import com.atlassian.jira.issue.customfields.persistence.CustomFieldValuePersister;
import com.atlassian.jira.issue.customfields.impl.FieldValidationException;
import java.math.BigDecimal;

@Scanned
public class MoneyCustomField extends AbstractSingleFieldType<BigDecimal> {

public MoneyCustomField(
@JiraImport CustomFieldValuePersister customFieldValuePersister,
@JiraImport GenericConfigManager genericConfigManager) {

super(customFieldValuePersister, genericConfigManager);
}

@Override
public String getStringFromSingularObject(final BigDecimal singularObject) {
if (singularObject == null)
return null;
else
return singularObject.toString();
}

@Override
public BigDecimal getSingularObjectFromString(final String string) throws FieldValidationException {
if (string == null)
return null;
try {
BigDecimal decimal = new BigDecimal(string);
if (decimal.scale() > 2) {
throw new FieldValidationException(
"Maximum of 2 decimal places are allowed.");
}
return decimal.setScale(2);
} catch (NumberFormatException ex) {
throw new FieldValidationException("Not a valid number.");
}
}

@Override
protected PersistenceFieldType getDatabaseType() {
return PersistenceFieldType.TYPE_LIMITED_TEXT;
}

@Override
protected BigDecimal getObjectFromDbValue(final Object databaseValue)
throws FieldValidationException {
return getSingularObjectFromString((String) databaseValue);
}

@Override
protected Object getDbValueFromObject(final BigDecimal customFieldObject) {
return getStringFromSingularObject(customFieldObject);
}
}

DPK J Community Leader Jan 16, 2020

@sgole  You wan to save tabular data or decimal data in your custom field?

If you want to save tabular data surely you need to change this.

Can you give me rough idea what you truly want to accomplish?

@DPK J  I want to create custom field of type table( same functioning like idalko table grid ). 

when i click on WBS(NO 1) button pop up will open(NO 2) as below img

image.png

and when i submit the form info. shown in table like shown below 

image.png

so i want to show the table on view issue page when click on create .

PS . i have created money custom field (as per requirement )

image.png

 

DPK J Community Leader Jan 17, 2020

Ok I guess it I fully got it.

Have your solved the storage part?

In view.vm page, you will need to fetch record based on issue and custom field and then display it.

no not done storage part what i have to do for that ? can u give me sample or something for view.vm file ...actually im new to jira and java as well 

DPK J Community Leader Jan 17, 2020

Ok.

I need to work on some sample implementation to get you started, I will share it in a day or two through BitBucket or GitHub.

okk thanks alot

DPK J Community Leader Jan 18, 2020

@sgole  Found some time and have created a sample for you available here

Details,

  • I have used Handsontable as sample grid implementation.
  • I'm saving data as text-area field, by marshaling data into JSON from table.
  • Table provide inline editing and context menu (by using right-click) to add more columns and rows.

Config screen,

Screenshot 2020-01-18 at 1.55.08 PM.png

View issue screen,

Screenshot 2020-01-18 at 1.49.39 PM.png

 

Edit issue screen,

Screenshot 2020-01-18 at 1.57.11 PM.png

 

Please don't use this in production without modification etc :-) it is just a sample.

Like sgole likes this

is it possible to change column name instead of A,B,C,D ? if "YES" then where? ....And also need to add child 

DPK J Community Leader Jan 20, 2020

Surely you can do that, look at Hansontable documentation for that, I have provided you with bare minimum implementation.

You have make those changes in view.vm and edit.vm files.

Ok thank you so much for your help it will help me alot .

hello again , @DPK J  I have set nestedRows: true of handsontable and can create parent child structure as you can see below ,

image.png 

but after click on update , i cant see same structure as above(doest show parent child structure ) on view page ,what should i do? please help me

 

image.png

DPK J Community Leader Jan 28, 2020

Have you made same changes in `view.vm` ?

Also, check how field data is saved and how it is rendered back, it might have something to do with this.

yes , i have done same changes in view.vm  . also if i remove the row it and update it is showing in view issue page

DPK J Community Leader Jan 28, 2020

You will need to see on what event you need to store data to 'textarea' field.

Like sgole likes this

ok thanks

hiii ,,, handsontable is paid so it is rejected by our organization .  can u give me other alternative ?

DPK J Community Leader Feb 03, 2020

@sgole  There many Data-table/grid implemetation available for JS these days, you can choose from them. Here is not so comprehensive list given in this thread - https://www.angularminds.com/blog/article/15-useful-javascript-based-data-grid-libraries-for-web-app-development.html

 

I have used Handsontable just because the zip was already available on my office computer :-).

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you