Foros del Web » Programando para Internet » Javascript »

Cómo accedo al valor de una Celda en un Datagrid

Estas en el tema de Cómo accedo al valor de una Celda en un Datagrid en el foro de Javascript en Foros del Web. Buenas a todos. Estoy tratando ingresar datos a una tabla desde un datagrid. Buscando en Internet encontre este código el cual he acondicionado a mi ...
  #1 (permalink)  
Antiguo 24/06/2013, 21:06
 
Fecha de Ingreso: abril-2013
Mensajes: 53
Antigüedad: 11 años
Puntos: 0
Pregunta Cómo accedo al valor de una Celda en un Datagrid

Buenas a todos.

Estoy tratando ingresar datos a una tabla desde un datagrid. Buscando en Internet encontre este código el cual he acondicionado a mi necesida. Pero no he podido acceder valor de cada celda para guardarlo en la tabla.

agrego el código.
Código HTML:
	var products = [];
		$(function(){
			$('#tt').datagrid({
				title:'Ingreso de Referidos',
				iconCls:'icon-edit',
				width:800,
				height:250,
				singleSelect:true,
				idField:'nident',
				url:'data/datagrid_data.json',
				columns:[[
				        	{field:'nident',title:'C&eacutedula',width:90,align:'center',editor:'text'},
                                                {field:'productid',title:'Nombre',width:150,align:'center',editor:'text'},
					{field:'listprice',title:'Apellido',width:120,align:'center',editor:'text'},
					{field:'unitcost',title:'Tel&eacutefono',width:80,align:'center',editor:'numberbox'},
					{field:'attr1',title:'Centro Votaci&oacuten',width:180,align:'center',editor:'text'},
					{field:'status',title:'Mesa',width:50,align:'center',editor:'text'},
					{field:'action',title:'Action',width:80,align:'center',
						formatter:function(value,row,index){
							if (row.editing){
								var s = '<a href="#" onclick="saverow(this)">Save</a> ';
								var c = '<a href="#" onclick="cancelrow(this)">Cancel</a>';
								return s+c;
							} else {
								var e = '<a href="#" onclick="editrow(this)">Edit</a> ';
								var d = '<a href="#" onclick="deleterow(this)">Delete</a>';
								return e+d;
							}
						}
					}
				]],
				onBeforeEdit:function(index,row){
					row.editing = true;
					updateActions(index);
				},
				onAfterEdit:function(index,row){
					row.editing = false;
					updateActions(index);
				},
				onCancelEdit:function(index,row){
					row.editing = false;
					updateActions(index);
				}
			});
		});
		function updateActions(index){
			$('#tt').datagrid('updateRow',{
				index: index,
				row:{}
			});
		}
		function getRowIndex(target){
			var tr = $(target).closest('tr.datagrid-row');
			return parseInt(tr.attr('datagrid-row-index'));
		}
		function editrow(target){
			$('#tt').datagrid('beginEdit', getRowIndex(target));
		}
		function deleterow(target){
			$.messager.confirm('Confirm','Esta Seguro?',function(r){
				if (r){
					$('#tt').datagrid('deleteRow', getRowIndex(target));
				}
			});
		}
		function saverow(target){
			$('#tt').datagrid('endEdit', getRowIndex(target));
		}
		function cancelrow(target){
			$('#tt').datagrid('cancelEdit', getRowIndex(target));
		}
		function insert(){
			var row = $('#tt').datagrid('getSelected');
			if (row){
				var index = $('#tt').datagrid('getRowIndex', row);
			} else {
				index = 0;
			}
			$('#tt').datagrid('insertRow', {
				index: index,
				row:{
				}
			});
			$('#tt').datagrid('selectRow',index);
			$('#tt').datagrid('beginEdit',index);
		}
	</script>
</head> 

Etiquetas: jquery-ajax
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:02.