navbar in sqlform.grid

92 views
Skip to first unread message

Yebach

unread,
Dec 29, 2014, 9:30:31 AM12/29/14
to web...@googlegroups.com
Hello

My navbar user button does not show dropdown options when I am in a view where SQLFORM.grid is? 

Any suggestions why?

Jim S

unread,
Dec 29, 2014, 10:40:33 AM12/29/14
to web...@googlegroups.com
Can you show some code?


-Jim

Vid Ogris

unread,
Dec 30, 2014, 2:39:00 AM12/30/14
to web...@googlegroups.com
This is the part of html in my layout.html


{{if auth.is_logged_in():}}
<div class="dropdown pull-right">
<button data-toggle="dropdown" class="btn btn-default navbar-btn">
<span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;{{=auth.user.first_name}}&nbsp;{{=auth.user.last_name}}&nbsp;&nbsp;<span class="caret"></span>
</button>
<ul aria-labelledby="dropdown" role="menu" class="dropdown-menu">
<li role="presentation"><a role="menuitem" tabindex="-1" href="{{=URL('default', 'user', args='logout')}}">{{=T('Logout')}}</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="{{=URL('default', 'user', args='profile')}}">{{=T('Edit profile')}}</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="{{=URL('default', 'user', args='change_password')}}">{{=T('Change password')}}</a></li>
</ul>
</div>
{{pass}}

It fails to work only at views where i have SQLFORM.grid

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/sjQoTm-XHgw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Lep pozdrav 

Vid Ogris


Jim S

unread,
Dec 30, 2014, 8:23:44 AM12/30/14
to web...@googlegroups.com
Can you show your view file where the grid is included?

-Jim


On Monday, December 29, 2014 8:30:31 AM UTC-6, Yebach wrote:

Vid Ogris

unread,
Dec 30, 2014, 8:33:32 AM12/30/14
to web...@googlegroups.com
My file 

{{extend 'layout.html'}}
{{include 'web2py_ajax.html'}}
<script>
$(function(){
$('.activateButton').click(function(){
turnusId = $(this).val();
$.ajax({
type: 'POST',
url: '{{=URL('settings', 'activateTurnus.json')}}',
data: {value: turnusId},
   dataType: 'json',
success: function(result){
//console.log("OK");
location.reload(true);
//$('#tablediv').load(document.URL +  ' #thisdiv');
},
error: function(){
// console.log("Ni OK");
// TODO ERROR MSG v kolkor se ni nč zgodivo
}
});
     
 });
$('.deleteButton').click(function(){
        turnusId = $(this).val();
        $.ajax({
            type: 'POST',
            url: '{{=URL('settings', 'deleteTurnus.json')}}',
            data: {value: turnusId},
            dataType: 'json',
            success: function(result){
                //console.log("OK");                    
                location.reload(true);
                //$('#tablediv').load(document.URL +  ' #thisdiv');
            },
            error: function(){
            //  console.log("Ni OK");
            // TODO ERROR MSG v kolkor se ni nč zgodivo
            }
        });
    });
});

var ColorPicker = function(){
var picker = $('input[name=sh_color]');
   picker.ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
   $(el).val(hex);
   $(el).ColorPickerHide();
   $(el).parent().css('background', '#'+hex);
},
onBeforeShow: function () {
   $(this).ColorPickerSetColor(this.value);
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
picker.each(function() {
if (this.value) {
   $(this).parent().css('background', '#' + this.value);
  
}
});
}; 
function compareTime(start, end) {
  
  var s1 = start.split(":")[0] * 3600 + start.split(":")[1] * 60;
  var s2 = end.split(":")[0] * 3600 + end.split(":")[1] * 60;
  //console.log(s1,s2);
  if (s1 > s2) {
  result = (86400 - s1) + s2;
  
  }
  else {
  result = Math.abs(s1 - s2);// Gets difference in seconds
  }
  return result
}
//alert(dateCompare("12:40:13","20:01:01"));
$(document).ready(function() {
$('.time').clockpicker({
donetext: doneText,
autoclose: true
});
ColorPicker();
jQuery.timeEntry.setDefaults({showSeconds: false});
///Pogledamo če je kje vv gruidu None da se ne kaže
//console.log($('.web2py_htmltable'));
//nastavimo polje lenght da je read only ker se vrednost zračuna
//$('#shift_sh_length1').attr("disabled", true) 
$('#shift_sh_code').prop('readonly', true);
$('#shift_sh_code').css( 'background-color', 'DarkGray');
$('#shift_sh_length1').prop('readonly', true);
$('#shift_sh_length1').css( 'background-color', 'DarkGray');
$('#shift_sh_length2').prop('readonly', true);
$('#shift_sh_length2').css( 'background-color', 'DarkGray');
$('#shift_sh_duration').prop('readonly', true);
//polja turnus code in duration se računjo tako za dur1 in dur2 
$( ".time" ).change(function() {
//length1
start  = $('#shift_sh_start1').val(),
end = $('#shift_sh_end1').val();
var dur = compareTime(start,end)/ 60;
$('#shift_sh_length1').val(dur);
//length2
start2  = $('#shift_sh_start2').val(),
end2 = $('#shift_sh_end2').val();
if (start2){
var codeBeg1 = start.split(":")[0] + start.split(":")[1];
var codeEnd1 = end.split(":")[0] + end.split(":")[1];
var codeBeg2 = start2.split(":")[0] + start2.split(":")[1];
var codeEnd2 = end2.split(":")[0] + end2.split(":")[1];
var tCodeL = codeBeg1 +'-' + codeEnd1 + '&' + codeBeg2 + '-' + codeEnd2; 
$('#shift_sh_code').val(tCodeL);
var dur2 = compareTime(start2,end2)/ 60;
$('#shift_sh_length2').val(dur2);
$('#shift_sh_duration').val(dur + dur2);
}
else  {
$('#shift_sh_length2').val(null);
//code
var beg = start.split(":")[0] + start.split(":")[1];
var ed = end.split(":")[0] + end.split(":")[1];
var tCode = beg +"-" + ed; 
$('#shift_sh_code').val(tCode);
$('#shift_sh_duration').val(dur);
}
});
});

</script>
<style>

.web2py_form {
width: 100%;
}

.w2p_fw {
width: 70%;
}

.generic-widget {
height : 110%;
}

.affix {
top: 60px;
}
.input-group {
width: 100%;
}
.row {
margin-bottom: 10px;
}
.sectionHeader {
margin-bottom: 0;
}
</style>
<head>

<title>{{ =response.title + " - " +T('Shifts')}} </title>
</head>


<h1>{{=T('Edit shifts')}}</h1>
<h3>{{=T('Active shifts')}}</h3>
<div class="col-md-12">
{{=grid_shifts}}
</div>

<!-- Ful grd if ampak dela -->
<!-- In  nimam pojma zakaj OR operator ne dela-->
{{if ((str((request.url, request.env.query_string)).find("new") < 0)):}}
    {{if ((str((request.url, request.env.query_string)).find("edit") < 0)):}}   
<div class="col-md-12" id = "inactiveShifts">
<h3>{{=T('Inactive shitfs')}}</h3>
<div class="col-md-12">
<div class="table-responsive"> 
    <table class="table table-striped table-bordered">
    <thead>
   <th>{{=T('Code')}}</th>
   <th>{{=T('Name')}}</th> 
   <th>{{=T('Start')}}</th>
   <th>{{=T('End')}}</th>
   <th>{{=T('Length 1')}}</th>
   <th>{{=T('Start 2')}}</th>
   <th>{{=T('End 2')}}</th>
   <th>{{=T('Length 2')}}</th>
  <th>{{=T('Note')}}</th>
  <th>{{=T('Activate')}}</th>
  <th>{{=T('Delete')}}</th>
  </tr>
  </thead>
  <tbody>
  {{for rec in query_inactive:}}
  <tr>
   <td>{{=rec['sh_code']}}</td>
   <td>{{=rec['sh_name']}}</td> 
   <td>{{=rec['sh_start1']}}</td>
   <td>{{=rec['sh_end1']}}</td>
   <td>{{=rec['sh_length1']}}</td>
   <td>{{=rec['sh_start2']}}</td>
   <td>{{=rec['sh_end2']}}</td>
   <td>{{=rec['sh_length2']}}</td>
   <td>{{=rec['sh_note']}}</td>
   <td><button type="button" id = "activateButton" class="activateButton glyphicon glyphicon-ok" value="{{=rec['id']}}"></button></td>
   <td><button type="button" id = "deleteButton" class="deleteButton glyphicon glyphicon-trash" value="{{=rec['id']}}"></button></td>
  </tr>
 {{pass}}
 {{pass}}
 </tbody>
</table>
</div>
</div>
</div>
{{pass}}


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/sjQoTm-XHgw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jim Steil

unread,
Dec 30, 2014, 8:37:41 AM12/30/14
to web...@googlegroups.com
Have you tried removing all of your javascript and css to see if it works?

-Jim

Vid Ogris

unread,
Jan 2, 2015, 10:08:26 AM1/2/15
to web...@googlegroups.com
I tried and it is the same. If i click on inspect element everything is there but the dropdown is not shown

Alex Glaros

unread,
Jan 2, 2015, 2:16:42 PM1/2/15
to web...@googlegroups.com
just guessing

do you have the "requires" clause in your db.py file?  E.g.:

db.yourTable.yourField.requires = IS_NULL_OR(IS_IN_DB(db, db.otherTable.otherField, '%(fieldName)s',zero=T('choose one')))

Yebach

unread,
Jan 8, 2015, 3:43:50 AM1/8/15
to web...@googlegroups.com
Do you mean in auth tables or other tables
In auth tables I  do not have, only thing is I added one field

I have in other tables

Alex Glaros

unread,
Jan 8, 2015, 11:36:16 AM1/8/15
to web...@googlegroups.com
not auth tables

just in your specific table for the specific field that does not drop down

Vid Ogris

unread,
Jan 12, 2015, 2:37:46 AM1/12/15
to web...@googlegroups.com
Yes
this is my db.py for one of those views

db.define_table('shift',
                Field('sh_organisation' , 'reference organization', label = T('Organization')),
                Field('sh_code', type= 'string', length = 256, label = T('Code')),
                Field('sh_status', type= 'integer', label = T('Status'), widget = SQLFORM.widgets.options.widget, default = 1),
                Field('sh_name', type= 'string', length = 256 ,label = T('Name')),
                Field('sh_color', type= 'string',label = T('Color')), # widget = color_widget, 
                Field('sh_start1', type= 'time',length = 4, label = T('Start'),requires = IS_NOT_EMPTY(error_message=T('Insert start time')),represent=repr),
                Field('sh_end1', type= 'time', label = T('End'),requires=IS_NOT_EMPTY(error_message=T('Insert end time')),represent=repr),
                Field('sh_length1', type= 'integer', label = T('Length 1'),represent=repr),
                Field('sh_start2', type= 'time', label = T('Start 2'),represent=repr),
                Field('sh_end2', type= 'time', label = T('End 2'), requires=IS_NOT_EMPTY(error_message=T('Insert second end time')) if request.post_vars.sh_start2 else None,represent=repr),
                Field('sh_length2', type= 'integer', label = T('Length 2'),represent=repr),
                Field('sh_start3', type= 'time', label = T('Start 3')),
                Field('sh_end3', type= 'time',label = T('End ')),
                Field('sh_length3', type= 'integer', label = T('Length 3')),
                Field('sh_start4', type= 'time', label = T('Start 4')),
                Field('sh_end4', type= 'time',label = T('End 4')),
                Field('sh_length4', type= 'integer', label = T('Length 4')),
                Field('sh_start5', type= 'time', label = T('Start 5')),
                Field('sh_end5', type= 'time', label = T('End 5')),
                Field('sh_length5', type= 'time', label = T('Length 5')),
                Field('sh_duration', type= 'integer', label = T('Duration')),
                Field('sh_duration1', type= 'integer', label =T('Duration 2')),
                Field('sh_note', type= 'text', label = T('Note')),
                migrate=settings.migrate
                )

2015-01-08 17:36 GMT+01:00 Alex Glaros <alexg...@gmail.com>:
not auth tables

just in your specific table for the specific field that does not drop down

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/sjQoTm-XHgw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Glaros

unread,
Jan 12, 2015, 3:27:06 AM1/12/15
to web...@googlegroups.com
I'm a beginner who is guessing, but I don't see the IS_IN_DB in the requires clauses.  Can you try that?
Reply all
Reply to author
Forward
0 new messages