1. 在表格的下方添加一个链接【显示/隐藏列】
【显示/隐藏列】
2. 用javascript写一段函数
3. 后端写一个接view.py
def showhidecolumns(request): initial_list = ['host_name', 'service_tag','motable__hosttype_list__name','motable','receive_date','user_list__dept_list__bl_list__bl_name','user_list__dept_list__dept_name','user_list', 'pcstatustable', \ 'site_list','asset_code','ownername','user_list__work_category__name'] if request.method == 'GET': includes_list=request.session.get('includes_list',[]) if len(includes_list) > 0: initial_list = includes_list columns_list = request.session.get('columns_list_session') #print(columns_list) obj = showhidecolumnsform(request,initial={'sh':initial_list}) return render(request, 'showhidecolumns.html' ,{'obj':obj}) else: obj = request.POST.getlist('sh') request.session['includes_list']=obj #print('obj',obj) excludes = request.session.get('columns_list_session') excludes_dict = dict(excludes) for i in obj: #print(str(i)) del excludes_dict[i] #print(tuple(excludes_dict.keys())) request.session['excludes_list'] = tuple(excludes_dict.keys()) return HttpResponse('
设置成功!')
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)