JQuery - Visualizar Links en Jquery Bootgrid

 
Vista:
Imágen de perfil de miguel
Val: 23
Ha mantenido su posición en JQuery (en relación al último mes)
Gráfica de JQuery

Visualizar Links en Jquery Bootgrid

Publicado por miguel (5 intervenciones) el 25/09/2017 18:59:51
Hola a todos, hoy tengo un nuevo problema ya que necesito mostrar enlaces en mi CRUD el cual estoy realizando con JQuery Bootgrid pero no entiendo como lograrlo ... si alguien sabe de una solucion o pueda orientarme gracias!

dejo el codigo donde creo la Tabla!!!


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST REACH DATATABLE</title>
<link rel="stylesheet" href="dist/bootstrap.min.css" type="text/css" media="all">
<link href="dist/jquery.bootgrid.css" rel="stylesheet" />
<script src="dist/jquery-1.11.1.min.js"></script>
<script src="dist/bootstrap.min.js"></script>
<script src="dist/jquery.bootgrid.min.js"></script>
</head>
<body>
	<?php include "view/navbar.php"; ?>
	<div class="container">
      <div class="">
        <div class="col-sm-12">
		<div class="well clearfix">
			<div class="pull-right"><button type="button" class="btn btn-sm btn-primary" id="command-add" data-row-id="0">
			<span class="glyphicon glyphicon-plus"></span> Record</button></div></div>
		<table id="product_grid" class="table table-striped table-hover" width="80%" cellspacing="0" data-toggle="bootgrid">
			<thead>
				<tr>
					<th data-column-id="id_prod" data-type="numeric" data-identifier="true">Id Prod</th>
					<th data-column-id="Part_number">Part Number</th>
					<th data-column-id="num_parte">Numero de parte</th>
					<th data-column-id="Pack_ml">Presentacion</th>
					<th data-column-id="Usein_prod">Use in</th>
					<th data-column-id="Hiperlink">Hiperlink</th>
					<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
				</tr>
			</thead>
		</table>
    </div>
      </div>
    </div>
 
<div id="add_model" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Add Substance</h4>
            </div>
            <div class="modal-body">
                <form method="post" id="frm_add">
				<input type="hidden" value="add" name="action" id="action">
                  <div class="form-group">
                    <label for="name" class="control-label">Part Number:</label>
                    <input type="text" class="form-control" id="part" name="part"/>
                  </div>
                  <div class="form-group">
                    <label for="salary" class="control-label">Num parte:</label>
                    <input type="text" class="form-control" id="numpart" name="numpart"/>
                  </div>
				  <div class="form-group">
                    <label for="salary" class="control-label">Presentacion:</label>
                    <input type="text" class="form-control" id="pack" name="pack"/>
                  </div>
                  <div class="form-group">
                    <label for="salary" class="control-label">Use in:</label>
                    <input type="text" class="form-control" id="usein" name="usein"/>
                  </div>
                  <div class="form-group">
                    <label for="salary" class="control-label">Hiperlink</label>
                    <input type="text" class="form-control" id="hiper" name="hiper"/>
                  </div>
 
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" id="btn_add" class="btn btn-primary">Save</button>
            </div>
			</form>
        </div>
    </div>
</div>
<div id="edit_model" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Edit Substance</h4>
            </div>
            <div class="modal-body">
                <form method="post" id="frm_edit">
				<input type="hidden" value="edit" name="action" id="action">
				<input type="hidden" value="0" name="edit_id" id="edit_id">
                  <div class="form-group">
                    <label for="name" class="control-label">Part Number:</label>
                    <input type="text" class="form-control" id="edit_part" name="edit_part"/>
                  </div>
                  <div class="form-group">
                    <label for="salary" class="control-label">Num parte::</label>
                    <input type="text" class="form-control" id="edit_num" name="edit_num"/>
                  </div>
				  <div class="form-group">
                    <label for="salary" class="control-label">Presentacion:</label>
                    <input type="text" class="form-control" id="edit_pack" name="edit_pack"/>
                  </div>
                  <div class="form-group">
                    <label for="salary" class="control-label">Use in:</label>
                    <input type="text" class="form-control" id="edit_use" name="edit_use"/>
                  </div>
                  <div class="form-group">
                    <label for="salary" class="control-label">Hiperlink:</label>
                    <input type="text" class="form-control" id="edit_hiper" name="edit_hiper"/>
                  </div>
 
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" id="btn_edit" class="btn btn-primary">Save</button>
            </div>
			</form>
        </div>
    </div>
</div>
</body>
</html>
<script type="text/javascript">
$( document ).ready(function() {
 
	var grid = $("#product_grid").bootgrid({
		ajax: true,
		rowSelect: true,
		post: function ()
 
		{
			/* To accumulate custom parameter with the request object */
			return {
				id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
			};
		},
 
		url: "Response/response-product.php",
		formatters: {
	        "commands": function(column, row)
	        {
	            return "<button type=\"button\" class=\"btn btn-xs btn-warning command-edit\" data-row-id=\"" + row.id_prod + "\"><span class=\"glyphicon glyphicon-edit\"></span></button> " +
                "<button type=\"button\" class=\"btn btn-xs btn-danger command-delete\" data-row-id=\"" + row.id_prod + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>";
	        }
	    }
   }).on("loaded.rs.jquery.bootgrid", function()
{
    /* Executes after data is loaded and rendered */
    grid.find(".command-edit").on("click", function(e)
    {
        //alert("You pressed edit on row: " + $(this).data("row-id"));
		var ele =$(this).parent();
		var g_id = $(this).parent().siblings(':first').html();
        var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
console.log(g_id);
console.log(g_name);
 
		//console.log(grid.data());//
		$('#edit_model').modal('show');
		if($(this).data("row-id") >0) {
 
            // collect the data
            $('#edit_id').val(ele.siblings(':first').html()); // in case we're changing the key
            $('#edit_part').val(ele.siblings(':nth-of-type(2)').html());
            $('#edit_num').val(ele.siblings(':nth-of-type(3)').html());
            $('#edit_pack').val(ele.siblings(':nth-of-type(4)').html());
	        $('#edit_use').val(ele.siblings(':nth-of-type(5)').html());
			$('#edit_hiper').val(ele.siblings(':nth-of-type(6)').html());
 
		} else {
		 alert('Now row selected! First select row, then click edit button');
		}
 
    }).end().find(".command-delete").on("click", function(e)
 
    {
 
		var conf = confirm('Delete ' + $(this).data("row-id") + ' items?');
		//alert('Deleted succesful');
 
        if(conf){
            $.post('Response/response-product.php', { id: $(this).data("row-id"), action:'delete'}
                , function(){
                    // when ajax returns (callback),									
					$("#product_grid").bootgrid('reload');
 
            });
			//$(this).parent('tr').remove();
			//$("#product_grid").bootgrid('remove', $(this).data("row-id"))
        }
    });
});
 
function ajaxAction(action) {
	data = $("#frm_"+action).serializeArray();
	$.ajax({
	  type: "POST",
	  url: "Response/response-product.php",
	  data: data,
	  dataType: "json",
	  success: function(response)
	  {
		$('#'+action+'_model').modal('hide');
 
		$("#product_grid").bootgrid('reload');
	  }
	});
}
 
$( "#command-add" ).click(function() {
  $('#add_model').modal('show');
});
$( "#btn_add" ).click(function() {
  ajaxAction('add');
});
$( "#btn_edit" ).click(function() {
  ajaxAction('edit');
});
$("#product_grid").bootgrid({
    searchSettings: {
        delay: 100,
        characters: 3
    }
});
});
</script>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder