Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented dropdown actions using bootstrap and tether #2038

Merged
merged 7 commits into from
Mar 29, 2017

Conversation

ismcagdas
Copy link
Member

@ismcagdas ismcagdas commented Mar 29, 2017

This extension depends on bootstrap v.3.x (https://github.com/twbs/bootstrap) and tether (https://github.com/HubSpot/tether). So in order to use it, jquery.jtable.record-actions.js must be added after jtable and both bootstrap and tether libraries must be referenced.

Example definition of an actions field is:

fields: {
    actions: { //'actions' is not a special name, but just another field name.
        type: 'record-actions', //introducing a new field type
        cssClass: 'btn btn-xs btn-primary blue', //this class is added to dropdown button if defined.
        text: '<i class="fa fa-cog"></i> Actions <span class="caret"></span>',//text or html can be used
        items: [{
            text: 'Edit record',
            action: function(data) {
                //TODO: Delete record
               //data parameter contains record property
            }
        }, {
            text: 'Delete record',
            action: function(data) {
                //TODO: Edit record
               //data parameter contains record property
            }
        }]
    },
    //...other fields
}

Also, if you want to show/hide a dropdown conditionally, you can define a function named "visible" to your dropdown list item which returns a boolean. If all dropdown list items are invisible, then main dropdown button becomes invisible as well.

@@ -715,7 +715,10 @@
return this._getDisplayTextForDateRecordField(field, fieldValue);
} else if (field.type == 'checkbox') {
return this._getCheckBoxTextForFieldByValue(fieldName, fieldValue);
} else if (field.options) { //combobox or radio button list since there are options.
}else if (field.type == 'record-actions') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core file should not be depend on extensions. Also jquery.jtable.record-actions.js should be completely an isolated extension rather than including to main jtable bundle.

@hikalkan hikalkan added this to the v2.5.0 milestone Mar 29, 2017
@hikalkan hikalkan merged commit bcd862d into volosoft:master Mar 29, 2017
@hikalkan
Copy link
Member

Thanks a lot.

@dasguptahirak
Copy link

@ismcagdas
Please guide how to use.
Share some example.

@ismcagdas
Copy link
Member Author

Hi,

The comment above contains an example usage, did you try it ?
Or are you asking a full example of it ?

@dasguptahirak
Copy link

@ismcagdas
Yes I need full example.

@ismcagdas
Copy link
Member Author

Hi,

I don't have time for preparing full example right now but yhe usage is very simple.

  • Just include jquery.jtable.record-actions.js after jtable.
  • Also include bootstrap and tether javascript files before jtable.
  • and add actions field defined above into your jtable definition, that's it.

Thanks.

@cangunaydin
Copy link

Hello,
It can be also good to send the jquery object reference for the anchor tag to the action method. I am trying to open a child table which needs a reference for the closest table row. or is there another way that i can get the reference?

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants