Of course, if we offer the user the opportunity to customize the display of individual entities, it makes sense to offer the same functionality for lists of entities. If you run crm4.py
and click on the Contacts menu item, you will see a list as follows:
You will notice that in the column containing the telephone numbers, those beginning with a plus sign are shown in a bold font. This will give a visible hint that this is probably a foreign number that needs some special code on your telephone switch.
The customization itself is a small piece of JavaScript that is inserted at the end of the page that shows the list of contacts:
Chapter10/customizationexample3.html
<script>
var re = new RegExp("^\\s*\\+");
$("td:nth-child(4)").each(function(i){
if($(this).text().match(re)){
$(this).css({'font-weight':'bold'})
};
});
</script>
It uses jQuery to iterate over all <td>
elements, which is the fourth child of their...