Problem using inline editing with Patternfly

Problem using inline editing with Patternfly

cwelchcwelch Posts: 18Questions: 4Answers: 0

I'll see if I can get a test link up for this, but it is a bit of a challenge to isolate it out of the rather large code base I'm working on.

The problem is using inline editing with the patternfly frame work.

The example is pretty simple, just a one column table for this example, HTML is:

{% block content %}

Broker List
Name
{% block scripts %}
<script>
      var editor;

      $(document).ready(function() {
          editor = new $.fn.dataTable.Editor({
              ajax: "/api/brokers/editor/?format=datatables",
              table: "#brokers",
              fields: [{
                  label: "Name:",
                  name: "name",
              },
              ]
          });

          // Activate the editor on click of a table cell
          $('#brokers').on( 'click', 'tbody td:not(:last-child)', function (e) {
              //editor.bubble( this );
              editor.inline( this, {
                  onBlur: 'submit'
              } );
          });

          var table = $('#brokers').DataTable( {
              "serverSide": true,
              dom: "Bfrtip",
              "ajax": "/api/brokers/?format=datatables",
              "columns": [
                  {"data": "name"},
                  {
                      data: null,
                      defaultContent: '',
                      className: 'select-checkbox',
                      orderable: false
                  },
              ],
              select: true,
              buttons: [
                  {extend: "create", editor: editor},
                  {extend: "edit", editor: editor},
                  {extend: "remove", editor: editor}
              ]
          });
          table.buttons().container()
              .appendTo($('.col-md-6:eq(0)', table.table().container()));
      });
</script>
{% endblock %}

{% endblock %}
</body>
</html>

The issue that comes up is that when the row is selected the text disappears. I've isolated this change in behaviour to when the Patternfly css/patternfly-additions.min.css style is present.

Is there a way to customize the td entry generated by DataTables for the rows with AJAX data such that I can revert the entry to a bootstrap style td as it works fine until the patternfly-additions are included?

I'll see if I can work around the issue by playing with the table classes in the mean time.

Thanks in advance!

This question has an accepted answers - jump to answer

Answers

  • cwelchcwelch Posts: 18Questions: 4Answers: 0
    edited April 2020

    Another way to solve it would be if I could turn off the patternfly context around the table some how. I need the context present on the sheet for the navigation bar, but I can live with plain bootstrap formatting for the table.

    Any suggestions on how I might achieve that?

    The patternfly context gets loaded like this:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    
    <!--[if IE 9]><html lang="en-us" class="ie9"><![endif]-->
    <!--[if gt IE 9]><!-->
    <html lang="en-us">
    <!--<![endif]-->
      <head>
        <title>Development Application</title>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=Edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
        {% block extra_head %}
        {% load static %}
        <link rel="shortcut icon" href="{% static 'img/favicon.ico' %}">
        <!-- iPad retina icon -->
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="{% static 'img/apple-touch-icon-precomposed-152.png' %}">
        <!-- iPad retina icon (iOS < 7) -->
        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="{% static 'img/apple-touch-icon-precomposed-144.png' %}">
        <!-- iPad non-retina icon -->
        <link rel="apple-touch-icon-precomposed" sizes="76x76" href="{% static 'img/apple-touch-icon-precomposed-76.png' %}">
        <!-- iPad non-retina icon (iOS < 7) -->
        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="{% static 'img/apple-touch-icon-precomposed-72.png' %}">
        <!-- iPhone 6 Plus icon -->
        <link rel="apple-touch-icon-precomposed" sizes="120x120" href="{% static 'img/apple-touch-icon-precomposed-180.png' %}">
        <!-- iPhone retina icon (iOS < 7) -->
        <link rel="apple-touch-icon-precomposed" sizes="114x114" href="{% static 'img/apple-touch-icon-precomposed-114.png' %}">
        <!-- iPhone non-retina icon (iOS < 7) -->
        <link rel="apple-touch-icon-precomposed" sizes="57x57" href="{% static 'img/apple-touch-icon-precomposed-57.png' %}">
    **    <link rel="stylesheet" href="{% static 'css/patternfly.min.css' %}" >
        <link rel="stylesheet" href="{% static 'css/patternfly-additions.min.css' %}" >**
    
        <link rel="stylesheet" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.min.css">
        <link rel="stylesheet" href="https://cdn.datatables.net/buttons/1.6.1/css/buttons.dataTables.min.css">
        <link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css">
        
        <link rel="stylesheet" href="{% static 'css/editor.dataTables.min.css' %}">
    
        <!-- Add additional CSS in static file -->
        <link rel="stylesheet" href="{% static 'css/styles.css' %}">  
    
    
        <script src="//code.jquery.com/jquery-3.3.1.js"></script>
        <script src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
        <script src="https://cdn.datatables.net/buttons/1.6.1/js/dataTables.buttons.min.js"></script>
        <script src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
        <script src="/static/js/dataTables.editor.js"></script>
        
        <script src="{% static 'js/patternfly.min.js' %}"></script>
    
        {% endblock %}
      </head>
    

    So I'd be looking for a way to turn off the patternfly style sheet around the table.

    Thanks in advance!

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • cwelchcwelch Posts: 18Questions: 4Answers: 0

    Sorry for the code formatting, just found the formater needed, will use it in future.

  • allanallan Posts: 61,714Questions: 1Answers: 10,103 Site admin
    Answer ✓

    I haven't used patternfly I'm afraid, but very likely there is a styling conflict. Using right click, Inspect would be the way I'd look into what styles are being applied.

    There is an inline editing example here that you might be able to use as a base for replicating this issue so w can take a look at it?

    Thanks,
    Allan

  • cwelchcwelch Posts: 18Questions: 4Answers: 0

    This suggestion was very helpful and allowed me to get to a solution.

    Others may run into a similar conflict, so here is how I resolved it:

    1) I inspected the element and this allowed me to see the various styles being applied to the inline edit row.

    2) I knew from my previous debugging that the mischief was coming from paternfly-additions.min.css so I looked for a reference to a style in this file.

    3) This allowed me to browse to the specific style in the patternfly-additions readily letting me know which of the table select patterns was the particular one causing the problems.

    4) I then started doing modification in the style editor, commenting out the attributes and was able to turn off the attribute causing the problem.

    Thanks for your inspection suggestion! I haven't worked much with complex style sheet usage so this was very helpful to learn how to diagnose and solve style problems.

This discussion has been closed.