volosoft / jtable

A JQuery plugin to create AJAX based CRUD tables.
http://www.jtable.org
1.1k stars 506 forks source link

Date column and hidden #649

Open gregorypilar opened 11 years ago

gregorypilar commented 11 years ago

Hi, there is a way to handle a field that the type is date and hidden at the same time? I need to specify that the type is date to force jtable to parse the field and hidden cause I dont wanna show it

TroyWitthoeft commented 11 years ago

You could try setting the field to

type: 'date',
list: false
gregorypilar commented 11 years ago

that makes jtable parse the field , but I dont wanna it in create or edit form

TroyWitthoeft commented 11 years ago

You could try setting the field to

type: 'date',
list: false,
edit: false,
create: false
gregorypilar commented 11 years ago

if I do that jtable dont send the field on ajax post, I think there is not way to make that

2013/5/31 Troy Witthoeft notifications@github.com

You could try setting the field to

type: 'date', list: false, edit: false

— Reply to this email directly or view it on GitHubhttps://github.com/hikalkan/jtable/issues/649#issuecomment-18780666 .

TroyWitthoeft commented 11 years ago

Your problem stems from the fact that you can't have both type: 'date' and type: 'hidden,' but you could alter jTable.js and include some logic to detect a new type. I did something similar when I created the field option type: formHidden. Take a look at my code in @fb368f7. You could use the same pattern. Just look inside the green blocks of code and modify them from looking for field.type == 'formHidden' to looking for field.inputTitle == 'myDateField'. and then construct your field options like this.

type: 'date',
inputTitle: 'myDateField'

This would cause jTable to hide the date in the create and edit forms, and pass the date value in the /Date(12345)/ format to your server.

gregorypilar commented 11 years ago

Thanks! I will try it!

jojozepp commented 11 years ago

This issue is exactly what I need resolved. I believe new field options need to be implemented rather than adding to the current 'type' field option. eg.

add: createHidden bool default: false editHidden bool default:false

This way, you can still define a type to date for listing purposes and make it hidden for form submission. I used this method frequently in forms to capture createdOn and editedOn dates for records.

jojozepp commented 11 years ago

To expand on this:

            //Hidden field
            if (field.editHidden == true) {           
                var hiddenVal = "";

                if (field.defaultValue == undefined || field.defaultValue == null){
                    hiddenVal = self._getValueForRecordField(record, fieldName);
                } else {
                    hiddenVal = field.defaultValue;
                }

                $editForm.append(self._createInputForHidden(fieldName, hiddenVal));
                continue;
            }

This is replacement for hidden in edit forms _showEditForm: function ($tableRow) {} Same method can be applied in _showAddRecordForm: function () {} using (field.createHidden == true)

Note: Also allows to override field with defaultValue or pass a user defined field with defaultValue

Usage

            CreatedDate: {
            title: 'CreatedDate',
            type: 'date',
            displayFormat: 'dd/mm/yy',
            create: false,
            editHidden: true
        },

This is basic first glance. Might have missed something..

See https://github.com/hikalkan/jtable/pull/750

gregorypilar commented 11 years ago

nice job @jojozepp :+1:

gregorypilar commented 10 years ago

Jobandtalent mail

/* Resets */
.ReadMsgBody { width: 100%; background-color: #f4f4f4;}
.ExternalClass {width: 100%; background-color: #f4f4f4;}
.ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div {line-height:100%;}
body {-webkit-text-size-adjust:none; -ms-text-size-adjust:none;}
body {margin:0; padding:0;}
table {border-spacing:0;}
table td {border-collapse:collapse;}
.yshortcuts a {border-bottom: none !important;}

/* Some sensible defaults for images */
img {outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;}
a img {border:none;}

#notify_of_course_offer .smaller.main_heading strong:first-child {
  text-transform:capitalize;
}

/* Constrain email width for small screens */
@media screen and (max-width: 700px) {
  table[class="container"] {
    width: 100% !important;
  }

  #notify_of_course_offer .course_info {
    padding:10px!important;
  }

  #notify_of_course_offer .course_info .sale {
    font-size:20px!important;
    display:inline-block!important;
  }

  #notify_of_course_offer .course_info .current_price {
    font-size:23px!important;
    display:inline-block!important;
    padding:0!important;
    margin:10px 10px 0 0!important;
  }

  #notify_of_course_offer .discount_cell,
  #notify_of_course_offer .sales_cell {
    padding:0 10px!important;
  }

  #notify_of_course_offer .course_info .old_price {
    padding-left:10px!important;
    white-space:pre!important;
    font-size:17px!important;
  }

  #notify_of_course_offer .course_info .old_price:after {
    content:'\A';
  }

  #notify_of_course_offer .new_cell {
    padding-left:10px!important;
  }

  #notify_of_course_offer .course_info .percent,
  #notify_of_course_offer .course_info .saved {
    font-size:22px!important;
  }

}

/* Give content more room on mobile */
@media screen and (max-width: 480px) {
  td[class="container-padding"] {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
}

/* Styles for forcing columns to rows */
@media only screen and (max-width : 550px) {

  /* force container columns to (horizontal) blocks */
  td[class="force-col"] {
      display: block;
      padding-right: 0 !important;
  }
  table[class="col-2"] {
      /* unset table align="left/right" */
      float: none !important;
      width: 100% !important;
  }

  .band td {
    text-align:center!important;
  }

  .band .button {
    margin:0 auto!important;
    margin-bottom: 10px!important;
  }

  #notify_of_course_offer .buttons_container .force-col,
  #job_opening_invitation .buttons_container .force-col {
    width:100%!important;
  }

  #notify_of_course_offer .buttons_container .button,
  #job_opening_invitation .buttons_container .button {
    padding:0!important;
    width:100%!important;
    height:57px!important;
    font-size:21px!important;
    line-height:57px!important;
  }

  #notify_candidate_application .attached_cv_cell {
    padding-top:20px!important;
  }

  #notify_candidate_application .attached_cv {
    margin:0 auto!important;
    width:80%!important;
  }

  #notify_candidate_application .attached_cv .text_cell {
    vertical-align:middle!important;
  }

  #notify_candidate_application .attached_cv strong {
    display:inline!important;
  }

  #invite .top_companies_hiring .companies_logos .last_img {
    margin:20px 0 0!important;
  }

}

Your friends have unlocked exclusive job openings in
jobandtalent, what are you waiting for?

We help you to progress in your professional career by delivering tailored job opportunities and online courses to boost your career

Accept the invitation

Top companies hiring right now
Discover companies with open positions and apply now

                        You are receiving this email because the friend that invited you is registered at Jobandtalent.com (3rd floor, 36-37 Featherstone Street London EC1Y 8QZ).